Пример #1
0
    async Task PrepArmySoldiers()
    {
        // wait for signal to allow RoundWon signal to process in Combat.cs firstx`
        await ToSignal(GetTree().CreateTimer(0.1f), "timeout");

        CityInfoResource currentCity = CityInfo.Instance.currentCity;

        // make the amount of soldiers specified for this round
        int newSoldiersThisRound = currentCity.numSoldiersPerRound[CombatInfo.Instance.currentRound - 1];

        for (int i = 0; i < newSoldiersThisRound; i++)
        {
            Enums.ArmyGunTypes gunType    = currentCity.soldierGunTypes[soldierNum];
            int            zoneIndex      = currentCity.soldierZoneIndex[soldierNum];
            CombatArmyZone zoneToDeployTo = armyZones[zoneIndex];

            // for each zone, both:
            // 1. add it to the list which is used by the deploy function
            // 2. and prepare the soldiers in that zone
            zonesToDeployTo.Add(zoneToDeployTo);
            await zoneToDeployTo.PrepArmySoldier(soldierNum, gunType);

            soldierNum++;
            zoneLastDeployedTo = zoneToDeployTo;
        }
    }
Пример #2
0
    // figure out the placement of the solider
    // called by CombatArmyCreator during the round switch when the vfx are happening
    async public Task PrepArmySoldier(int soliderNum, Enums.ArmyGunTypes gunType)
    {
        CombatArmySoldier newSoldier = armySoldierScene.Instance <CombatArmySoldier>();

        newSoldier.gunType = gunType;

        // hide the soldier and keep trying random positions till it isnt colliding with any of the existing soldiers
        newSoldier.Visible = false;
        armySoldiers.AddChild(newSoldier);

        do
        {
            PlaceSoldierRandomPos(newSoldier);
        }while (await IsSoliderColliding(newSoldier));

        newSoldier.Visible = true;

        // re-calculate the spawn and off-screen spawn positions
        // also set the soldier's position to the off-screen value; prevously it was the final position to check for collisions
        Vector2 spawnPos          = newSoldier.Position;
        Vector2 offScreenSpawnPos = new Vector2(newSoldier.Position.x + spawnOffset, newSoldier.Position.y);

        newSoldier.Position = offScreenSpawnPos;

        preparedSoldiers.Add(newSoldier, spawnPos);
    }
Пример #3
0
    public override void _Ready()
    {
        animSprite = GetNode <AnimatedSprite>("AnimatedSprite");

        GD.Randomize();
        uint random = GD.Randi() % 3;

        Enums.ArmyGunTypes weapon     = (Enums.ArmyGunTypes)random;
        string             animString = "move_" + weapon.ToString().ToLower();

        animSprite.Play(animString);

        // for ALL the guards, not just the one who found the scientist
        Events.levelFailed += OnLevelFailed;
    }