//==================================================================================================== void OnCollisionEnter(UNITY.Collision other) { if (other.gameObject.tag == "Alien") { var alien = other.gameObject.GetComponent <ALIEN>(); alien.Hit(); PLAYER.SubPower(5); Color = COLOR.white; GameObject.AudioSource.Play(); } }
//----------------------------------------------------------------------------------------------------- void OnCollisionEnter(UnityEngine.Collision other) { if (other.gameObject.tag == "Alien") { var alien = other.gameObject.GetComponent <ALIEN>(); alien.Hit(); //Add Score PLAYER.AddScore(10); // Destroy(collider.gameObject); Destroy(LaserObject); } }
//==================================================================================================== // ■ BOMB //==================================================================================================== public void Bomb() { if (PLAYER.GetBomb()) { var obj = (GAMEOBJECT)Instantiate(BombObject); obj.SetActive(true); obj.Tag = "Bomb"; var p = Transform.Position; obj.Transform.Parent = BombInstances.Transform; var bomb = obj.Transform.Find("Bomb"); bomb.Position = p - math.normalize(p) * GridDistance; bomb.Transform.LookAt(p); } }
//==================================================================================================== // ■ HIT //==================================================================================================== public void Hit(int hit = 1) { HitFlag = true; HitTime = TIME.realtimeSinceStartup; HitCount -= hit; HitCount = math.max(0, HitCount); if (HitCount == 0) { PLAYER.AddScore(100); Destroy(GameObject, 1.0f); Die = true; var camera = GAMEOBJECT.Find("Main Camera").Camera; ScorePosition = camera.WorldToScreenPoint(transform.position); } Color = COLOR.white; Scale = 1.5f; GameObject.AudioSource.Play(); }
//==================================================================================================== // ■ UPDATE //==================================================================================================== void Update() { var center = GAMEOBJECT.Find("Center").GetComponent <CENTER>(); var position = center.transform.position; var rotation = center.transform.rotation; transform.position = math.lerp(transform.position, position, 5.0f * TIME.deltaTime); transform.rotation = math.slerp(transform.rotation, rotation, 5.0f * TIME.deltaTime); //Flash Color.r = math.lerp(Color.r, OriginalColor.r, 0.03f); Color.g = math.lerp(Color.g, OriginalColor.g, 0.03f); Color.b = math.lerp(Color.b, OriginalColor.b, 0.03f); var ship = Transform.Find("Body/Ship"); var renderer = ship.GameObject.Renderer; var material = renderer.material; material.SetColor("_EmissionColor", Color); //Set Height // transform.position = Vector3.Normalize(transform.position - center) * ShipHeight; //////////////////////////////// /// WALL UPDATE //////////////////////////////// if (PLAYER.Shield > 0) { if (CurrentWall != null) { var p = transform.position; if (math.distance(p, OldPosition) > WallUpdateDistance) { CurrentWall.AddPoint(p); OldPosition = p; PLAYER.SubShield(1); } } } else { StopWall(); } //////////////////////////////// /// ITEM LOAD //////////////////////////////// if (PLAYER.GameOver == false) { //Power Load if (TIME.realtimeSinceStartup - PowerLoadTime > PowerLoadSpeed) { PLAYER.AddPower(1); PowerLoadTime = TIME.realtimeSinceStartup; } //Shield Load if (TIME.realtimeSinceStartup - ShieldLoadTime > ShieldLoadSpeed) { PLAYER.AddShield(1); ShieldLoadTime = TIME.realtimeSinceStartup; } } }