// Use this for initialization void Start() { if (gameControllerObject == null) { gameControllerObject = GameObject.FindGameObjectWithTag("GameController"); } gameManager = gameControllerObject.GetComponent <GameManager>(); PlayerRigidBody = this.GetComponent <Rigidbody2D>(); Dodging = false; NewPos = transform.position; animator = GetComponent <Animator>(); AS = GetComponent <AudioSource>(); shootPosition = transform.Find("ShootPosition"); particles = transform.Find("ParticleEffect").gameObject; animator.SetLayerWeight(BASE_ANIMATION_LAYER, 0f); animator.SetLayerWeight(SHOTGUN_ANIMATION_LAYER, 100f); animator.SetLayerWeight(LAZER_ANIMATION_LAYER, 0f); healthbar = GameObject.FindGameObjectWithTag("Health Bar").GetComponent <HealthBar>(); cooldownBar = GameObject.FindGameObjectWithTag("Cooldown Bar").GetComponent <CooldownBar>(); radiationEffect = GameObject.FindGameObjectWithTag("RadiationEffect"); if (radiationEffect) { radiationEffect.SetActive(false); } }
//Add spell to the cooldown list //Precondition: isFull() = false; public bool add(string root, float cooldown, Ref <float> curr_time, Ref <bool> is_finished) { CooldownBar c = new CooldownBar(bar_prefab, transform, root, transform.position, curr_time, cooldown); c.bar.transform.Translate(Vector3.down * spells.Count * bar_distance, 0); c.bar.transform.Translate(Vector3.left * 0.25F, 0); spells.Add(c); refs.Add(is_finished); flots.Add(curr_time); StartCoroutine(timer(cooldown, curr_time, is_finished, c)); return(true); }
// Use this for initialization void Start() { fire_bullets = null; bullet_prefab = Resources.Load("Bullet"); swap_attack_prefab = Resources.Load("Swap"); stop_bullet_fire_time = -fire_bullet_delay; swap_attack_cooldown_start = -swap_attack_cooldown; swap_attack_cooldown_bar = swap_attack_cooldown_bar_go.GetComponent <CooldownBar>(); player_comp = this.GetComponent <Player>(); player_manager_comp = this.GetComponent <PlayerManager>(); player = player_comp.player; }
// keep track of time, update bars, and delete bars if done IEnumerator timer(float finish_time, Ref <float> curr_time, Ref <bool> is_finished, CooldownBar c) { is_finished.Obj = false; while (curr_time.Obj < finish_time) { yield return(new WaitForEndOfFrame()); yield return(new WaitWhile(() => BattleManagerS.main.pause)); curr_time.Obj += Time.deltaTime; } spells.Remove(c); GameObject.Destroy(c.bar.gameObject); is_finished.Obj = true; curr_time.Obj = 0; rePosition(); }
public UserSprite(CatAndMouseGame game, Texture2D texture, Vector2 position) : base(game, texture, position) { Cooldown = new CooldownBar(game, COOLDOWN_MAX, COOLDOWN_BAR_WIDTH, this); }