Пример #1
0
 public Ant(AntType antType, Coordinates coordinates)
 {
     AntType         = antType;
     Coordinates     = coordinates;
     PrewCoordinates = Coordinates;
     _random         = new Random();
 }
Пример #2
0
    private TurnError ActAnalyse(Ant ant, HexDirection direction)
    {
        if (direction == HexDirection.CENTER)
        {
            return(TurnError.ILLEGAL);
        }

        Vector2Int target = CoordConverter.MoveHex(ant.gameCoordinates, direction);

        TurnError tileError = CheckAnalyzability(target);

        if (tileError != TurnError.NONE)
        {
            return(tileError);
        }

        // Set all the fields of the response to 0
        TerrainType terrainType = TerrainType.NONE;
        AntType     antType     = AntType.NONE;
        bool        isAllied    = false;
        Value       foodValue   = Value.NONE;
        bool        egg         = false;

        if (terrain[target.x][target.y] == null || terrain[target.x][target.y].tile == null)
        {
        }                                                                                        // Leave everything like that
        else
        {
            terrainType = terrain[target.x][target.y].tile.Type;

            if (terrain[target.x][target.y].ant == null)
            {
            }                                                // Leave everything like that
            else
            {
                antType  = terrain[target.x][target.y].ant.Type;
                isAllied = terrain[target.x][target.y].ant.team.teamId == ant.team.teamId;

                terrain[target.x][target.y].ant.eventInputs.Add(new EventInputBump(CoordConverter.InvertDirection(direction)));
            }

            if (terrain[target.x][target.y].food == null)
            {
            }                                                 // Leave everything like that
            else
            {
                foodValue = ValueConverter.Convert(terrain[target.x][target.y].food.value, Const.FOOD_SIZE);
            }

            egg = terrain[target.x][target.y].egg != null;
            if (egg)
            {
                isAllied = terrain[target.x][target.y].egg.team.teamId == ant.team.teamId;
            }
        }

        ant.analyseReport = new AnalyseReport(terrainType, antType, egg, isAllied, foodValue, null);

        return(TurnError.NONE);
    }
 public void Create(AntType type)
 {
     using (var context = new NurseryContext())
     {
         context.AntTypes.Add(type);
         context.SaveChanges();
     }
 }
Пример #4
0
	public Ant[] getAntsOfType(AntType type){
		List<Ant> myAnts = new List<Ant>();
		foreach(Ant ant in allAnts){
			if(ant.type == type){
				myAnts.Add(ant);
			}
		}
		return myAnts.ToArray();
	}
Пример #5
0
 public CommunicateReport(AntType type, AntMindset mindset, Value hp, Value energy, Value carriedFood, AntWord word)
 {
     this.type        = type;
     this.mindset     = mindset;
     this.hp          = hp;
     this.energy      = energy;
     this.carriedFood = carriedFood;
     this.word        = word;
 }
Пример #6
0
 public AnalyseReport(TerrainType terrainType, AntType antType, bool isAllied, bool egg, Value foodValue, List <PheromoneDigest> pheromones)
 {
     this.terrainType = terrainType;
     this.antType     = antType;
     this.egg         = egg;
     this.isAllied    = isAllied;
     this.foodValue   = foodValue;
     this.pheromones  = pheromones;
 }
Пример #7
0
    public Ant SpawnAnt(AntType type, AntProperty props = AntProperty.None)
    {
        var obj = Instantiate(antPrefab, parent);

        obj.transform.position = checkpoints[0].position;

        var ant = obj.GetComponent <Ant>();

        ant.checkpoints = checkpoints;
        ant.props       = props;
        ant.type        = type;
        return(ant);
    }
 public bool Validate(int age, AntType type)
 {
     if (type == AntType.Queen && age < 35)
     {
         return(true);
     }
     else if (age < 5)
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
Пример #9
0
    public void Pop()
    {
        GameManager.Instance.popSound.Play();
        hp--;

        if (hp > 0)
        {
            return;
        }

        GameManager.Instance.money++;

        switch (type)
        {
        case AntType.Black:
            Destroy(gameObject);
            return;

        case AntType.White:
            type = AntType.Black;
            break;

        case AntType.Blue:
            type = AntType.White;
            break;

        case AntType.Green:
            type = AntType.Blue;
            break;

        case AntType.Yellow:
            type = AntType.Green;
            break;

        case AntType.Pink:
            type = AntType.Yellow;
            break;

        case AntType.Brown:
            type = AntType.Pink;
            Split();
            break;
        }

        UpdateType();
    }
Пример #10
0
	public void LoadBlueprint (ProgramBlueprint blueprint)
	{

		antType = blueprint.antType;
		myAnts = blueprint.ants;

		foreach(Ant ant in myAnts){
			ant.SpawnPopup("YOU");
		}

		functions = new AntFunction[blueprint.availableFunctions.Length];
		for (int i = 0; i< blueprint.availableFunctions.Length; i++) {
			AntFunction func = new AntFunction ();
			func.LoadBlueprint (blueprint.availableFunctions [i]);
			functions [i] = func;
		}
	}
Пример #11
0
        public static Baby CreateBaby(AntType type)
        {
            switch (type)
            {
            case AntType.Babysitter:
                return(new Baby(AntType.Babysitter, currentAntId++, CurrentFactionId, babysitterTexture, 1, 1));

            case AntType.Soldier:
                return(new Baby(AntType.Soldier, currentAntId++, CurrentFactionId, soldierTexture, 1, 1));

            case AntType.Worker:
                return(new Baby(AntType.Worker, currentAntId++, CurrentFactionId, workerTexture, 1, 1));

            default:
                throw new System.Exception("Unable to create baby of this type");
            }
        }
Пример #12
0
        protected Ant(int health, int hunger, int id, int colonyID, int age, String location, AntType type)
        {
            HealthProperty       = health;
            HungerProperty       = hunger;
            IDProperty           = id;
            ColonyIDProperty     = colonyID;
            AgeProperty          = age;
            LocationProperty     = location;
            CarryingProperty     = Carrying.Nothing;
            StateProperty        = State.Standby;
            PheromoneProperty    = PheromoneEnum.ToNest;
            InNestProperty       = true;
            TypeProperty         = type;
            BeingCarriedProperty = false;
            MyAnthillProperty    = AntFarmForm.antHills[this.ColonyIDProperty];


            if (TypeProperty == AntType.Egg || TypeProperty == AntType.Queen)
            {
                MyAnthillProperty.AntsTotalProperty += 1;
            }
        }
Пример #13
0
 private Ant CheckForLocalAntTypeToCarry(AntType type, String location)
 {
     Ant foundAnt = null;
     try
     {
         for (int i = 0; i < (MyAnthillProperty.ants.Count - 1); i++)
         {
             if (MyAnthillProperty.ants[i].TypeProperty == type && MyAnthillProperty.ants[i].LocationProperty == location && MyAnthillProperty.ants[i].BeingCarriedProperty == false)
             {
                 foundAnt = MyAnthillProperty.ants[i];
                 i = (MyAnthillProperty.ants.Count - 1);
             }
         }
     }
     catch (NullReferenceException ex)
     {
         foundAnt = null;
     }
     return foundAnt;
 }
Пример #14
0
 public MajorWorkerViewModel(int Id, string name, AntType type, int age)
 {
 }
Пример #15
0
 /// <summary>
 /// Visszaadja a megadott típusú hangyákat
 /// </summary>
 /// <param name="Type">A keresett típus</param>
 /// <returns>A megadott típusú hangyák</returns>
 public static List<AntBase> FindByType(AntType Type)
 {
     List<AntBase> Found = new List<AntBase>();
     foreach (AntBase item in All) { if(Type == AntType.Any || item.Type == Type) { Found.Add(item); }}
     return Found;
 }
Пример #16
0
 /// <summary>
 /// Nyilvántartásba vesz egy hangyát a megadott típussal
 /// </summary>
 /// <param name="Ant">A hangya</param>
 /// <param name="Type">Milyen típusú hangya legyen?</param>
 /// <returns>A nyilvántartott hangya</returns>
 public static AntBase TrackAs(CorvinusAnt Ant, AntType Type)
 {
     if (Type == AntType.Any) { throw new ArgumentException("AntType.Any cannot be used here"); }
     if (Ants.AntBase.BaseList.Contains(Ant)) { return null; }
     try
     {
         switch (Type)
         {
             case AntType.Queen: return new Queen(Ant);
             case AntType.Explorer: return new Explorer(Ant);
             case AntType.SugarWorker: return new SugarWorker(Ant);
             case AntType.FruitWorker: return new FruitWorker(Ant);
             case AntType.Soldier: return new Soldier(Ant);
             default: throw new ArgumentException("Invalid ant type");
         }
     }
     catch (InvalidOperationException) { return null; }
 }
Пример #17
0
 public Baby(AntType type, uint antId, uint factionId, SFML.Graphics.Texture texture, byte width, byte height) :
     base(antId, factionId, texture, width, height)
 {
     Type = type;
 }