private void OnCollisionEnter2D(Collision2D collision)
    {
        //Debug.Log("Colliding with object " + collision.collider.gameObject.name + "...");

        if (collision.collider.gameObject.tag == "Missile")
        {
            //int damageSustained = Mathf.FloorToInt(collision.collider.gameObject.GetComponent<MissileTrajectory>().DamageValue);
            float damageSustained = collision.collider.gameObject.GetComponent <MissileTrajectory>().DamageValue;
            Destroy(collision.collider.gameObject);
            //Debug.Log("The wall is taking damage!");

            if (WallHP > 0)
            {
                WallHP -= damageSustained;
                if (WallHP <= 0)
                {
                    MissileSpawner spawner = FindObjectOfType <MissileSpawner>();
                    Debug.Log("The wall has been destroyed!");
                    int finalTime = spawner.GameTime;
                    spawner.MissilesEnabled = false;
                    Debug.Log("Final GameTime: " + finalTime);
                }
            }
        }
    }
Example #2
0
 void Start()
 {
     enemyMissaileControl = GameObject.Find("missileSpawnArea").GetComponent <MissileSpawner> ();
     HeroGO        = GameObject.Find("Hero");
     weaponControl = HeroGO.GetComponentInChildren <Weapon>();
     fpControl     = HeroGO.GetComponentInChildren <FirstPersonController>();
     moveControl   = HeroGO.GetComponent <CharacterController> ();
     sw            = new Stopwatch();
     sw.Start();
     guideText.text = "'게임명' 에 온 것을 환영함.";
     InvokeRepeating("StepProcess", termBetweenNextMessage, termBetweenNextMessage + 0.1f);
 }
 // Start is called before the first frame update
 void Awake()
 {
     if (MissileSpawner.Instance != null)
     {
         Destroy(gameObject);
         return;
     }
     else
     {
         Instance = this;
     }
 }
Example #4
0
    private void CreateSpawner(int index)
    {
        Transform spawnerPosition = new GameObject("Missile Spawner - Position").transform;
        spawnerPosition.SetParent(player, false);
        spawnerPosition.localRotation = Quaternion.Euler(0f, 0f, index * 360f / amountOfSpawners);

        MissileSpawner spawner = Instantiate<MissileSpawner>(missileSpawnerPrefab);
        spawner.name = "Missile Spawner";
        spawner.transform.SetParent(spawnerPosition, false);
        spawner.transform.localPosition = new Vector3(0f, radius, 0f);
        spawner.transform.localRotation = Quaternion.Euler(0f, 0f, 0f);
        spawner.transform.localScale = new Vector3(xScale, yScale, zScale);
        //spawner.gameObject.SetActive(false);
        missileSpawners.Add(spawner);
    }
    public void FireMissle(GameObject asteroid)
    {
        MissileSpawner spawner  = missileSpawners[0];
        float          distance = Mathf.Infinity;

        for (int i = 0; i < missileSpawners.Count; i++)
        {
            var dis = Vector3.Distance(missileSpawners[i].gameObject.transform.position, asteroid.transform.position);
            if (dis < distance)
            {
                distance = dis;
                spawner  = missileSpawners[i];
                Debug.Log("Spawner: " + i);
            }
        }

        spawner.SpawnMissile(asteroid);
    }
Example #6
0
    private void Awake()
    {
        spawner = GameObject.FindGameObjectWithTag("MinigameManager").GetComponent <MissileSpawner>();

        sprites[spawner.arrowDirection].SetActive(true);
    }
 private void Awake()
 {
     spawner = FindObjectOfType <MissileSpawner>();
 }
 void Start()
 {
     Instance           = this;
     _missileSpawnTimer = GameRules.Instance.MissileSpawnTimer;
     _missileSpawnCount = GameRules.Instance.MissileSpawnCount;
 }
Example #9
0
 // Use this for initialization
 void Awake()
 {
     spawner           = FindObjectOfType <MissileSpawner>();
     _trueBulletDamage = 1.0f;
 }