//Assign references protected void Assign() { //Assigning player components player = gameObject; //Since the skills will be a component to the player playerHealth = player.GetComponent <PlayerHealthMult> (); playerSkill = player.GetComponent <PlayerSkillMult> (); playerMovement = player.GetComponent <PlayerMovementMult> (); skillActivation = player.GetComponent <SkillActivation> (); button.image.sprite = Resources.Load(imagePath, typeof(Sprite)) as Sprite; button.GetComponent <Button> ().onClick.AddListener(() => { Activate(); }); //Assigning skill effect to the button }
bool attackCoolDown; //Indicator whether enemy is able to attack or not. void Awake() { //get all the players on the scene GameObject[] players = GameObject.FindGameObjectsWithTag("Player"); //Get the player that the enemy will track //It will track the player that is standing on the same 'bridge' for (int i = 0; i < players.Length; i++) { float playerLocationOffset = gameObject.transform.position.y - players[i].transform.position.y; if ((playerLocationOffset < 1) && (playerLocationOffset > -1)) { player = players[i]; playerHealth = players[i].GetComponent <PlayerHealthMult>(); } } enemyHealth = GetComponent <EnemyHealthMult>(); attackTimer = 2.0f; attackCoolDown = false; }
// Use this for initialization void Start() { playerHealth = gameObject.GetComponent <PlayerHealthMult> (); playerSkill = gameObject.GetComponent <PlayerSkillMult> (); playerMovement = gameObject.GetComponent <PlayerMovementMult> (); }