ltrout

PlayerManager

Dec 24th, 2015
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.16 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3. using UnityEngine.UI;
  4. using PlayerInfo;
  5. using EnemyInfo;
  6.  
  7. namespace Management
  8. {
  9.     public class PlayerManager : MonoBehaviour
  10.     {
  11.         [HideInInspector]public PlayerHealth PHealth;
  12.         public GameObject PlayerTank;
  13.         public Transform[] PlayerSpawn;
  14.         [HideInInspector] public GameObject Instance;
  15.         public Color PlayerColor;
  16.  
  17.         private PlayerMovement PMove;
  18.         private PlayerAttack PAttack;
  19.  
  20.         public void PSetup ()
  21.         {
  22.             PMove = Instance.GetComponent<PlayerMovement> ();
  23.             PAttack = Instance.GetComponent<PlayerAttack> ();
  24.  
  25.             MeshRenderer[] PRender = Instance.GetComponentsInChildren<MeshRenderer> ();
  26.  
  27.             for (int i = 0; i < PRender.Length; i++)
  28.             {
  29.                 PRender [i].material.color = PlayerColor;
  30.             }
  31.         }
  32.  
  33.         public void DisablePControl ()
  34.         {
  35.             PMove.enabled = false;
  36.             PAttack.enabled = false;
  37.         }
  38.  
  39.         public void EnablePControl ()
  40.         {
  41.             PMove.enabled = true;
  42.             PAttack.enabled = true;
  43.         }
  44.  
  45.         public void PSpawn ()
  46.         {
  47.             int randomSpawn = Random.Range (0, PlayerSpawn.Length);
  48.  
  49.             Instantiate (PlayerTank, PlayerSpawn[randomSpawn].position, PlayerSpawn[randomSpawn].rotation);
  50.         }
  51.     }
  52. }
Add Comment
Please, Sign In to add comment