示例#1
0
    // Format: <Spawn Time> <Size> <Preset> <Action Type> <Waypoint>,<Waypoint>,...
    // "2.5 Large Default AttackMove ArcherTower,SwordsmanTower"
    // "1 Individual Elite ForcedMove AbilityTower"
    private void AddSquad(string input)
    {
        float   spawnTime;
        Vector3 spawnLocation;

        char[]   delimiters = { ' ', ',' };
        string[] param      = input.Split(delimiters, StringSplitOptions.RemoveEmptyEntries);

        spawnTime = float.Parse(param [0]);
        SquadSize size = EnumUtil.FromString <SquadSize> (param [1]);
        Waypoint  wp   = EnumUtil.FromString <Waypoint> (param [4]);

        spawnLocation = Waypoints[wp];
        SquadLeaderType preset = EnumUtil.FromString <SquadLeaderType> (param [2]);
        //SquadBehavior behavior = EnumHelper.FromString<SquadBehavior> (param [3]);

        EnemySquad es = new EnemySquad((int)size, spawnTime, spawnLocation, UnitType.Peasant, preset);

        for (int i = 5; i < param.Length; ++i)
        {
            wp = EnumUtil.FromString <Waypoint> (param [i]);
            es.AddWaypoint(Waypoints [wp]);
        }
        es.AddWaypoint(Waypoints [Waypoint.King]);

        units.Add(es);
    }
    public EnemySquad(int size, float spawnTime, 
	                   Vector3 spawnLocation,
                       UnitType unitType,
                       SquadLeaderType leaderType = SquadLeaderType.None)
    {
        if (mSquadPrefab == null)
            mSquadPrefab = Resources.Load ("Squads/SquadPrefab") as GameObject;

        mSpawnLocation = spawnLocation;

        mSquadSize = size;
        mSpawnTime = spawnTime;
        mLeaderType = leaderType;
        mUnitType = unitType;

        mWaypoints = new List<Vector3> ();
    }
示例#3
0
    private void SpawnSquad(int size, Vector3 spawnLocation, SquadLeaderType leader, UnitType unitType)
    {
        GameObject o     = (GameObject)GameObject.Instantiate(mSquadPrefab);
        Squad      squad = o.GetComponent <Squad> ();

        UnitType squadLeaderType = UnitTypeFromPreset(leader);

        if (squadLeaderType == UnitType.None)
        {
            squadLeaderType = unitType; // squad leader is the same type as the unit
        }
        squad.AddUnits(squadLeaderType, spawnLocation, 1, Allegiance.AI);
        squad.AddUnits(unitType, spawnLocation, size - 1, Allegiance.AI);

        mSquad = squad;
        mSquad.SetDestination(mWaypoints [0]);
    }
示例#4
0
    public EnemySquad(int size, float spawnTime,
                      Vector3 spawnLocation,
                      UnitType unitType,
                      SquadLeaderType leaderType = SquadLeaderType.None)
    {
        if (mSquadPrefab == null)
        {
            mSquadPrefab = Resources.Load("Squads/SquadPrefab") as GameObject;
        }

        mSpawnLocation = spawnLocation;

        mSquadSize  = size;
        mSpawnTime  = spawnTime;
        mLeaderType = leaderType;
        mUnitType   = unitType;

        mWaypoints = new List <Vector3> ();
    }
示例#5
0
    private UnitType UnitTypeFromPreset(SquadLeaderType preset)
    {
        switch (preset)
        {
        case (SquadLeaderType.Default):
            return(UnitType.Peasant);

        case (SquadLeaderType.Melee):
            return(UnitType.Swordsman);

        case (SquadLeaderType.Ranged):
            return(UnitType.Archer);

        case (SquadLeaderType.Special):
            return(UnitType.Mage);

        case (SquadLeaderType.Elite):
            return(UnitType.Elite);

        default:
            return(UnitType.None);
        }
    }
    private void SpawnSquad(int size, Vector3 spawnLocation, SquadLeaderType leader, UnitType unitType)
    {
        GameObject o = (GameObject)GameObject.Instantiate (mSquadPrefab);
        Squad squad = o.GetComponent<Squad> ();

        UnitType squadLeaderType = UnitTypeFromPreset(leader);

        if (squadLeaderType == UnitType.None)
            squadLeaderType = unitType; // squad leader is the same type as the unit

        squad.AddUnits(squadLeaderType, spawnLocation, 1, Allegiance.AI);
        squad.AddUnits(unitType, spawnLocation, size - 1, Allegiance.AI);

        mSquad = squad;
        mSquad.SetDestination (mWaypoints [0]);
    }
 private UnitType UnitTypeFromPreset(SquadLeaderType preset)
 {
     switch (preset){
     case (SquadLeaderType.Default):
         return UnitType.Peasant;
     case (SquadLeaderType.Melee):
         return UnitType.Swordsman;
     case (SquadLeaderType.Ranged):
         return UnitType.Archer;
     case (SquadLeaderType.Special):
         return UnitType.Mage;
     case (SquadLeaderType.Elite):
         return UnitType.Elite;
     default:
         return UnitType.None;
     }
 }