Esempio n. 1
0
        public Actor harvester = null; // the harvester to protect

        #endregion Fields

        #region Constructors

        public HarvesterDefenseSquad(IranAI AI, SquadManager manager, SquadType squadtype, SquadRole squadrole)
            : base(AI, manager, squadtype, squadrole)
        {
            this.AI = AI;
            squadtype = SquadType.Tank;
            SetMaxSquadSize(2);
        }
Esempio n. 2
0
 public ShipSquad(IranAI AI, SquadManager manager, SquadType squadtype, SquadRole squadrole)
     : base(AI, manager, squadtype, squadrole)
 {
     this.AI = AI;
     squadtype = SquadType.Ship;
     SetMaxSquadSize(2);
     //            isready = true; // Important for creating new squads, if this doesn't get set somewhere the squad size will be unlimited
 }
Esempio n. 3
0
        public void AddToSquad(Actor unit, SquadType squadtype)
        {
            // Check if there's a a not full land-type squad and join it
            // I should be able to do this without the double query..
            if (squads.Where(a => !a.IsReady() && a.GetSquadType() == squadtype).Any())
            {
                squads.Where(a => !a.IsReady() && a.GetSquadType() == squadtype)
                    .FirstOrDefault().GetSquadMembers().Add(unit);
            }
            else // Otherwise create a new land-type squad, add our unit
            { // and add the squad to the squads list

                // Make sure we always have at least two defending squads
                ISquad newsquad = CreateSquad(squadtype);

                newsquad.GetSquadMembers().Add(unit);
                squads.Add(newsquad);
            }
        }
Esempio n. 4
0
		public Squad(HackyAI bot, SquadType type, Actor target)
		{
			Bot = bot;
			World = bot.World;
			Random = bot.Random;
			Type = type;
			Target = Target.FromActor(target);
			FuzzyStateMachine = new StateMachine();

			switch (type)
			{
				case SquadType.Assault:
				case SquadType.Rush:
					FuzzyStateMachine.ChangeState(this, new GroundUnitsIdleState(), true);
					break;
				case SquadType.Air:
					FuzzyStateMachine.ChangeState(this, new AirIdleState(), true);
					break;
				case SquadType.Protection:
					FuzzyStateMachine.ChangeState(this, new UnitsForProtectionIdleState(), true);
					break;
			}
		}
Esempio n. 5
0
        public Squad(HackyAI bot, SquadType type, Actor target)
        {
            this.bot = bot;
            this.world = bot.world;
            this.random = bot.random;
            this.type = type;
            this.target = Traits.Target.FromActor(target);
            fsm = new StateMachine();

            switch (type)
            {
                case SquadType.Assault:
                case SquadType.Rush:
                    fsm.ChangeState(this, new GroundUnitsIdleState(), true);
                    break;
                case SquadType.Air:
                    fsm.ChangeState(this, new AirIdleState(), true);
                    break;
                case SquadType.Protection:
                    fsm.ChangeState(this, new UnitsForProtectionIdleState(), true);
                    break;
            }
        }
Esempio n. 6
0
 public void HighlightPossible(SquadType squadType)
 {
     field.HighlightCells(highlightType, Position, maxMoveDistance, squadType);
 }
Esempio n. 7
0
 public Squad(IBot bot, SquadManagerBotModule squadManager, SquadType type) : this(bot, squadManager, type, null)
 {
 }
Esempio n. 8
0
		Squad RegisterNewSquad(SquadType type, Actor target = null)
		{
			var ret = new Squad(this, type, target);
			squads.Add(ret);
			return ret;
		}
Esempio n. 9
0
		// Use of this function requires that one squad of this type. Hence it is a piece of shit
		Squad GetSquadOfType(SquadType type)
		{
			return squads.FirstOrDefault(s => s.Type == type);
		}
Esempio n. 10
0
 public void SetSquadType(SquadType st)
 {
     SquadType = st;
 }
Esempio n. 11
0
        ISquad CreateSquad(SquadType squadtype)
        {
            /*            if (squads.Where(s => s.GetSquadRole() == SquadRole.DefendBase).Count() < 2)
                newsquad = new Squad(AI, this, squadtype, SquadRole.DefendBase);
            else */

            if (squadtype == SquadType.Tank)
            return new HarvesterDefenseSquad(AI, this, squadtype, SquadRole.AttackBase);
            else if (squadtype == SquadType.Air)
            return new AirSquad(AI, this, squadtype, SquadRole.AttackBase);
            else if (squadtype == SquadType.Land)
            return new Squad(AI, this, squadtype, SquadRole.AttackBase);
            else if (squadtype == SquadType.Ship)
            return new ShipSquad(AI, this, squadtype, SquadRole.AttackBase);

            return null; // Shouldn't happen
        }
Esempio n. 12
0
 public Squad(string _name, SquadType _type) : base(_name)
 {
     units       = new List <Unit>();
     squadType   = _type;
     displayName = _name;
 }
Esempio n. 13
0
    /// <summary>
    /// Creates a new SquadInstance
    /// </summary>
    /// <param name="node">The board node the </param>
    /// <param name="squadType"></param>
    /// <returns></returns>
    public static SquadInstance Create(Node node, SquadType squadType)
    {
        if (node.obstruction != null)
        {
            throw new System.Exception( "SquadInstance.Create() was called on a non-null terrain node's obstruction. Use SquadInstance.Replace() instead." );
        }

        GameObject go = GameObject.Instantiate(
            squadType.prefab,
            node.position,
            Quaternion.identity
            ) as GameObject;

        SquadInstance squadInstance = go.AddGetComponent<SquadInstance>();
        squadInstance.type = squadType;

        squadInstance.selectable = go.AddGetComponent<Selectable>();

        squadInstance.abilityContainer = new AbilityContainer();
        squadInstance.abilityContainer.caster = squadInstance.selectable;
        foreach (Ability a in squadType.staticData.abilities)
            squadInstance.abilityContainer.add( a );
        go.name = squadType.staticData.name;

        return squadInstance;
    }
Esempio n. 14
0
    public static void Replace(SquadInstance squadInstance, SquadType newType)
    {
        Node n = Board.instance.getNode( squadInstance.transform.position );
        if (n == null)
        {
            Debug.LogError( "The squadInstance you are trying to replace is not within the bounds of the Board. Something dun messed up." );
            return;
        }

        squadInstance.kill();
        n.obstruction = null;
        Create( n, newType );
    }
Esempio n. 15
0
    void AssignSquadCharacter(List <GeneratedBaseCharacter> squadCharacters, Transform panel, SquadType squadType)
    {
        // clear all items
        var children = panel.GetComponentsInChildren <SquadItem>();

        foreach (var child in children)
        {
            DestroyImmediate(child.gameObject);
        }
        var colors = squadType == SquadType.Squad ? new [] { "22b573", "0071bc", "006837" } : new [] { "603813", "603813" };

        // assigns
        for (var i = 0; i < squadCharacters.Count; i++)
        {
            var character = squadCharacters.ElementAtOrDefault(i);
            if (character == null)
            {
                continue;
            }
            var squadItem = Instantiate <SquadItem>(squadItemPrefab, Vector3.zero, Quaternion.identity, panel.transform);
            squadItem.character = character;
            squadItem.squadType = squadType;
            // display order
            squadItem.displayOrder.text = ((squadType == SquadType.Squad ? 0 : _list.squadCharacters.Count) + i + 1).ToString();
            // display order text's color
            var color = new Color();
            ColorUtility.TryParseHtmlString("#" + colors[i], out color);
            squadItem.displayOrder.color = color;
            // icon of job
            squadItem.iconJob.sprite = GetIconJobSprite(character.baseJob.label);
            // icon of class
            squadItem.iconClass.sprite = GetClassSpriteByLabel(character.baseClass.label);
            // job text
            squadItem.jobText.text = character.baseJob.label.ToString();
            // character name
            squadItem.characterName.text = character.characterName;
            // level
            squadItem.level.text = character.baseClass.level.ToString();
            // health
            squadItem.healthText.text = Mathf.RoundToInt(character.stats.currentHealth) + "/" + Mathf.RoundToInt(character.stats.maxHealth.GetValue());
        }
    }
Esempio n. 16
0
    public void PopulateSquadUIGrid(SquadType[] squadTypes)
    {
        foreach (Transform t in squadUIGrid.transform)
        {
            Destroy( t.gameObject );
        }

        foreach (SquadType s in squadTypes)
        {
            GameObject entry = Instantiate( Resources.Load( "prefabs/gui/Entry" ) ) as GameObject;
            Vector3 scale = entry.transform.localScale;

            entry.transform.parent = squadUIGrid.transform;
            entry.transform.localScale = scale;

            entry.name = s.staticData.name;

            UIEventListener.Get( entry ).onClick += OnChooseSquad;
        }
    }
Esempio n. 17
0
 private void OnChooseSquad(GameObject go)
 {
     string text = go.name;
     if (text == null) return;
     chosenSquadType = TypeContainer<SquadType>.get( text );
     mode = LevelEditorMode.Squad;
 }
Esempio n. 18
0
 // Use of this function requires that one squad of this type. Hence it is a piece of shit
 Squad GetSquadOfType(SquadType type)
 {
     return(squads.FirstOrDefault(s => s.type == type));
 }
Esempio n. 19
0
		public Squad(HackyAI bot, SquadType type) : this(bot, type, null) { }
Esempio n. 20
0
 Squad RegisterNewSquad(SquadType type)
 {
     return(RegisterNewSquad(type, null));
 }
Esempio n. 21
0
 public Squad(HackyAI bot, SquadType type) : this(bot, type, null)
 {
 }
Esempio n. 22
0
 public Squad(IranAI AI, SquadManager manager, SquadType squadtype, SquadRole squadrole)
 {
     this.AI = AI;
     this.manager = manager;
     this.squadtype = squadtype;
     this.world = AI.world;
     this.squadrole = squadrole;
     members = new List<Actor>();
 }