Inheritance: MonoBehaviour
Exemplo n.º 1
0
    //updates influence map when turret is added/removed
    void applyToInfluenceMap(GameObject turret, bool add)
    {
        Vector2 turretPos = new Vector2(turret.transform.position.x, turret.transform.position.z);
        turret  t         = ((turret)turret.GetComponent("turret"));

        for (int i = (int)(turretPos.x - t.range); i <= (int)(turretPos.x + t.range); i++)
        {
            for (int j = (int)(turretPos.y - t.range); j <= (int)(turretPos.y + t.range); j++)
            {
                if (i >= 0 && j >= 0 && i < gc.gridWidth && j < gc.gridHeight)
                {
                    if (Mathf.Abs(turretPos.x - i) + Mathf.Abs(turretPos.y - j) <= t.range)
                    {
                        float inf = typeToInfluence((turretType)t.identifier);
                        if (add)
                        {
                            influence[i, j] += inf; totalInfluence += inf;
                        }
                        else
                        {
                            influence[i, j] -= inf; totalInfluence -= inf;
                        }
                    }
                }
            }
        }
    }
 public void applyToTurret(turret t)
 {
     t.takeDamage(damageAmount);
     if (t.getEnergy() <= 0){
         attacker.gainExp(weaponFired.getTechnology(),exp);
     }
 }
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 Start()
    {
        //This will get the Animator
        anim = gameObject.GetComponent<Animator>();

        //These will get the Scripts
        theCharacterMotorScript = gameObject.GetComponent<CharacterMotor2>();
        theEnemyChargeScript = gameObject.GetComponent<EnemyCharge>();
        theEnemyShootAIScript = gameObject.GetComponent<EnemyShootAI>();
        theEnemyShootingLRScript = gameObject.GetComponent<enemyShootingLR>();
        thePaceBetweenWallsScript = gameObject.GetComponent<PaceBetweenWalls>();
        theSingleShotEnemyScript = gameObject.GetComponent<singleShotEnemy>();
        theTurretScript = gameObject.GetComponent<turret>();
        theCharacterShotScript = gameObject.GetComponent<CharacterShot>();
    }
Exemplo n.º 5
0
    private void OnEnable()
    {
        t = (turret)target;

        ammoList = t.ammoLoop.ToList();

        targetObject = new UnityEditor.SerializedObject(t);

        shellEjector = targetObject.FindProperty("shellEjector");

        barrel = targetObject.FindProperty("barrel");

        muzzle = targetObject.FindProperty("muzzle");

        turretRotation = targetObject.FindProperty("turretRotation");

        barrelElavation = targetObject.FindProperty("barrelElevation");
    }
 // Once it's set to be a turret spwan point, it cannot be changed
 public void setTurret(turret turret)
 {
     myTurret = turret;
 }
Exemplo n.º 7
0
 private void Start()
 {
     turretscript = weapon.GetComponent <turret>();
 }