void OnTriggerEnter(Collider col) { ObjectProperty hitUnit = col.gameObject.GetComponent <ObjectProperty>(); Debug.Assert(null != this.owner, "Bullet's Owner is null"); isHit = true; //all projectile colliding game objects should be tagged "Enemy" or whatever in inspector but that tag must be reflected in the below if conditional if (null != hitUnit && hitUnit.ally != this.owner.ally) { //Debug.Log("hit-:" + col.gameObject.name); // Destroy(col.gameObject); // //add an explosion or something // //destroy the projectile that just caused the trigger collision // Destroy(gameObject); Unit obj = hitUnit.gameObject.GetComponent <Unit>(); if (obj && obj.IsAlive) { obj.OnDamage(owner); } this.ReturnToPool(); } else { Facade_Coroutine.DelaySeconds(this, () => { this.ReturnToPool(); }, 3); } }
// Use this for initialization void Awake() { instance = this; hDamageFlash.enabled = false; // HUD Damage notifyMap.Add(eNotifyHUD.Damage, (val) => { Color backup = hDamageFlash.color; Color color = backup; hDamageFlash.enabled = true; Facade_Coroutine.While(this, () => { if (color.a < 0.5) { color.a += ((Time.deltaTime > 0) ? Time.deltaTime : 0.03f); hDamageFlash.color = color; return(true); } Debug.Log("Flash Done"); hDamageFlash.color = backup; hDamageFlash.enabled = false; return(false); }); }); // HUD Kill Enemy notifyMap.Add(eNotifyHUD.Kill, (val) => { HUDDevDisplay.instance.Show("Score", GameData.instance.Score.ToString()); hScore.text = GameData.instance.Score.ToString(); }); }
// Use this for initialization void Start() { R.Create(); Facade_Coroutine.Sequnce(this, Facade_Coroutine.Wait(() => { // start at Map1 // if(!GameData.instance) { // GameData.instance = Singleton<GameData>.Instantiate(); // } return(!GameData.instance); }), Facade_Coroutine.Wait(() => { return(!SpawnManager.instance); }), Facade_Coroutine.Wait(() => { return(!GameManager.instance); }), Facade_Coroutine.Do(() => { GameManager.instance.ReadyToPlay(); }) ); }
// first time loaded public void ReadyToPlay() { isShowMenu = true; Debug.Log("Loading Start"); Color color = new Color(0, 0, 0, 1); Facade_Coroutine.While(this, () => { if (color.a > 0) { color.a -= ((Time.deltaTime > 0)? Time.deltaTime: 0.03f); imgLoading.color = color; return(true); } Debug.Log("Loading Done"); imgLoading.enabled = false; return(false); }); //imgLoading.color = new Color(0, 0, 0, 0); }
public static void Sequnce(MonoBehaviour go, params IEnumerator[] actions) { go.StartCoroutine(Facade_Coroutine.Chain(go, actions)); }