protected virtual void Awake() { // Get our controller. myController = GetComponent<Mouse_Input>(); if (myController == null) Debug.LogError(gameObject.name + " is missing a Controller!"); // Set destination position to current position. destinationPosition = transform.position; // TODO This is normally acquired from the model. We use a placeholder value here for testing. moveSpeed = 1.5f; }
public override void Init() { // hide the invulnerability shield(!) if (!godMode) { MakeVulnerable(); } else { MakeInvulnerable(); } // get a ref to the weapon controller weaponControl = myGO.GetComponent <Standard_SlotWeaponController>(); // tell weapon control who we are (so all weapon control can tell projectiles who sent them) weaponControl.SetOwner(ownerID); // if a player manager is not set in the editor, let's try to find one if (myPlayerManager == null) { myPlayerManager = myGO.GetComponent <BasePlayerManager>(); } myDataManager = myPlayerManager.DataManager; myDataManager.SetName("Player"); myDataManager.SetHealth(3); // update UI lives if (ownerID == 1) { // if our owner ID is 1, we must be player 1 GameController_IP.Instance.UpdateLivesP1(myDataManager.GetHealth()); } else { // we are player 2, so set that UI instead GameController_IP.Instance.UpdateLivesP2(myDataManager.GetHealth()); } if (isMouseControlled) { // if we are going to use mouse controls, add a mouse input controller mouse_input = gameObject.AddComponent <Mouse_Input>(); } didInit = true; }