// Set the Correct Animation Controller for the current weapon public void Start() { attaking = false; player = GameObject.FindGameObjectWithTag("Player"); movementController = player.GetComponent <MovementController>(); animator = GetComponent <Animator>(); effectContainer = transform.GetChild(0).gameObject; //Set weappon Interface values weaponInterface = this.GetComponent <WeaponInterface>(); weaponInterface.defaultSprite = this.GetComponent <SpriteRenderer>().sprite; weaponInterface.setValues(weapon.attakTime, weapon.cooldown, weapon.quantity, attaking, weapon.rotation, weapon.tooltip, weapon.damage); weaponInterface.setWeaponManager(player.GetComponent <WeaponManager>()); //Weapon Specific Initialazation Initialize(); }
/// Change weapon function /// Uses current weapon string to denote which object to set the playerweapon to. public void ChangeWeapon() { if (_currentWeapon == "Sword") { _playerWeapon = new Sword(); // default weapon } if (_currentWeapon == "Seed") { _playerWeapon = new Seed(); } if (_currentWeapon == "FireBall") { _playerWeapon = new FireBall(); } if (_currentWeapon == "WaterBall") { _playerWeapon = new WaterBall(); } }
public void ShowTowerInformation(TowerBehavior tower, Vector2?pos = null) { if (pos != null) { self.position = (Vector3)pos; } else { self.position = new Vector2(Screen.width / 2, Screen.height / 2); } titleText.text = tower.param.title; //requiredHeight += titleText.GetComponent<RectTransform>().sizeDelta.y; descriptionText.text = tower.param.description; //descriptionBox.sizeDelta = new Vector2(descriptionBox.sizeDelta.x, descriptionText.text.Length * 0.5f); //requiredHeight += descriptionBox.sizeDelta.y + 10; //self.sizeDelta = new Vector2(self.sizeDelta.x, requiredHeight); //ShowTowerStats(tower.weapon); if (weaponInterface == null) { weaponInterface = Instantiate(weaponInterfacePrefab, transform.position, Quaternion.identity, transform) .GetComponent <WeaponInterface>(); } weaponInterface.ShowWeapon(tower.weapon); weaponInterface.self.position = new Vector2 ( self.position.x + self.sizeDelta.x * 0.5f + weaponInterface.self.sizeDelta.x * 0.5f + GameManager.instance.interfaceManager.boxesSpacing, self.position.y ); lastTower = tower; lastPosition = (Vector2)self.position; self.gameObject.SetActive(true); }