12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485 |
- using UnityEngine;
- using System.Collections;
- public class Station : BattleObject
- {
- public enum State
- {
- Start,
- Idle,
- }
- public GameObject[] haloPrefabs;
- public CrystalBase crystalBase;
- private State state;
- private float startTime;
- private float buildDuration = 5f;
- public override void Init (Map map)
- {
- base.Init (map);
- SetState(State.Start);
- startTime = GameTime.time;
- hpRecoverSpeed = 0.025f;
- if(map.id == MapData.MapID.Challenge)
- _originMaxHp = hp = maxHp = 6000f;
- else
- _originMaxHp = hp = maxHp = 60000f;
- }
- public override TeamUtil.Team team {
- get {
- return base.team;
- }
- set {
- base.team = value;
- try
- {
- headBar.UpdateColor();
- GameObject haloObj = Instantiate<GameObject>(haloPrefabs[value.GetHashCode()-1]);
- haloObj.transform.SetParent(this.transform);
- haloObj.transform.localPosition = Vector3.zero;
- }
- catch(System.Exception e)
- {
- Debuger.LogException(e);
- }
- }
- }
- public void SetState(State state)
- {
- this.state = state;
- if(this.animation != null)
- this.animation.Play(state.ToString());
- }
- public State GetState()
- {
- return this.state;
- }
- void Update()
- {
- if(state == State.Start && GameTime.time - startTime > buildDuration)
- {
- SetState(State.Idle);
- }
- CheckHpRecover();
- DealBuff();
- }
- public override void Dead ()
- {
- base.Dead ();
- crystalBase.SetStation(null);
- MapItem mapItem = map.GetMapItem(crystalBase.id);
- if(mapItem != null)
- mapItem.Remove();
- }
- }
|