Exemplo n.º 1
0
    void createMissile(GameObject targetCreep)
    {
        GameObject newMissile = (GameObject)Instantiate(missileType, this.transform.position, this.transform.rotation);
        missile    m          = (missile)newMissile.GetComponent("missile");

        newMissile.tag = "Missile";
        m.target       = targetCreep.transform;
    }
Exemplo n.º 2
0
    public virtual void misslieHit(missile m)
    {
        Debug.Log("missile Hit被觸發");
        GameObject effobj = Instantiate(objectList.main.prafebList[effNo_hit], m.traget.gameObject.transform);

        effobj.transform.localPosition = Vector2.zero;
        Debug.Log("物件名稱:" + effobj.gameObject.name);
    }
Exemplo n.º 3
0
    // Update is called once per frame
    void Update()
    {
        if ((int)state == (int)gameState.battlePhase)
        {
            //continue spawning current wave
            sm.UpdateSpawn();

            //execute turret AI
            foreach (GameObject currentTurret in GameObject.FindGameObjectsWithTag("Turret"))
            {
                turret t = (turret)currentTurret.GetComponent("turret");
                t.Fire(new Vector2(9, 9));
            }

            //execute creep AI
            GameObject[] creeps = GameObject.FindGameObjectsWithTag("Creep");
            foreach (GameObject currentCreep in creeps)
            {
                creep c = (creep)currentCreep.GetComponent("creep");
                c.Seek(new Vector2(9, 9), currentPath, 10);
                c.updateStatuses();
            }

            //update missiles
            foreach (GameObject currentMissile in GameObject.FindGameObjectsWithTag("Missile"))
            {
                missile m = (missile)currentMissile.GetComponent("missile");
                m.Fly();
            }

            //check if wave is defeated
            if (creeps == null || creeps.Length == 0)
            {
                Debug.Log("here");
                if (sm.isWaveDefeated())
                {
                    updateAvailableUnits(sm.currentWave);
                    if (sm.currentWave == sm.totalWaves)
                    {
                        totalWin();
                    }
                    else
                    {
                        win();
                    }
                }
            }
            if (tm.selected == selectedState.creep && tm.selectedObject != null)
            {
                //apply stun
                creep c = (creep)tm.selectedObject.GetComponent("creep");
                c.applyStatus(creepStatus.stun, 3 * c.durationMultipliers[1]);
                //tm.selected = selectedState.none;
            }
            tm.selected  = selectedState.none;
            tm.clickable = true;
        }
    }
Exemplo n.º 4
0
    void launchMissile()
    {
        if (missileToLaunch.Count != 0)
        {
            missileStr info    = (missileStr)missileToLaunch[0];
            GameObject thisOne = Instantiate(missile);
            missile    thisMsl = thisOne.GetComponent <missile>();
            thisMsl.transform.position = info.startPos.transform.position;
            thisMsl.shooter            = info.startPos;

            thisMsl.initialSpeed = info.startPos.speed;

            if (info.targetOb != null)
            {
                thisMsl.aimTarget = info.targetOb;
            }
            else
            {
                thisMsl.aimTarget = null;
            }
            missileToLaunch.RemoveAt(0);
            launchMissile();
        }
    }
Exemplo n.º 5
0
 private void destorySelf(missile self)
 {
     Destroy(gameObject);
 }
 void Start()
 {
     missile missleCopy = InstantiateGenericsExample<Missile>(missile); 
 }
Exemplo n.º 7
0
 void wpnFire()
 {
     missile newM = Instantiate(missileObj, this.transform.position, this.transform.rotation);
 }