Example #1
0
 public ChoiceDescriptor(ActionType type, HexDirection direction, int quantity, AntWord word)
 {
     this.type      = type;
     this.direction = direction;
     this.quantity  = quantity;
     this.word      = word;
 }
Example #2
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;
 }
Example #3
0
    private TurnError ActCommunicate(Ant ant, HexDirection direction, AntWord word)
    {
        if (direction == HexDirection.CENTER)
        {
            return(TurnError.ILLEGAL);
        }

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

        TurnError tileError = CheckCommunicability(target, ant);

        if (tileError != TurnError.NONE)
        {
            if (tileError == TurnError.NOT_ALLY)
            {
                terrain[target.x][target.y].ant.eventInputs.Add(new EventInputBump(CoordConverter.InvertDirection(direction)));
            }
            return(tileError);
        }

        if (ant.CheckEnergy(Const.GIVE_COST))
        {
            ant.UpdateEnergy(-Const.GIVE_COST);
        }
        else
        {
            return(TurnError.NO_ENERGY);
        }

        Ant receptor = terrain[target.x][target.y].ant;

        // Gives the info to the emitter
        ant.communicateReport = new CommunicateReport(
            receptor.Type,
            receptor.mindset,
            ValueConverter.Convert(receptor.hp),
            ValueConverter.Convert(receptor.energy),
            ValueConverter.Convert(receptor.carriedFood),
            AntWord.NONE);

        // Gives the cmmunication to the receptor
        receptor.eventInputs.Add(new EventInputComunicate(CoordConverter.InvertDirection(direction), new CommunicateReport(
                                                              ant.Type,
                                                              ant.mindset,
                                                              ValueConverter.Convert(ant.hp),
                                                              ValueConverter.Convert(ant.energy),
                                                              ValueConverter.Convert(ant.carriedFood),
                                                              word)));

        return(TurnError.NONE);
    }
Example #4
0
 public static ChoiceDescriptor ChooseCommunicate(HexDirection direction, AntWord word)
 {
     return(new ChoiceDescriptor(ActionType.COMMUNICATE, direction, 0, word));
 }