Device-to-device (D2D) communications as an underlay to cellular networks can potentially improve the system throughput and reduce transmission delays between users, which, however, are largely limited by the battery lifetime of user equipment (UE). In this paper, we define the overall system survival time of a mobile cell and maximize it by jointly optimizing the resource allocation and power control (RAPC) for D2D and conventional cellular links. Considering that the UEs may have different levels of residual battery energy, we define the overall system survival time as the minimally expected battery lifetime among all transmitting UEs in a cell. Subject to the transmission rate requirement of each link, we formulate the joint optimization of RAPC as a non-linear programming problem, which is NP-hard. To solve it, we devise a game theory based distributed approach, where the links are considered as non-cooperative players with the overall system survival time as their utility function. We prove the existence of the Nash equilibrium in our RAPC game and propose a low-complexity algorithm to calculate each individual player's best response, given the strategies of other players. Numerical results show that our game theory based approach can significantly prolong the overall system survival time as compared with existing RAPC schemes. INDEX TERMS D2D communication, resource allocation and power control, overall system survival time, game theory.