Exemplo n.º 1
0
    public void Conquer(int actionSlimeId, Vector2 tileVector)
    {
        RawSlime actionSlime = FindSlimeById(actionSlimeId);
        TileData toConquer   = matrix.getTile((int)tileVector.x, (int)tileVector.y);

        actionSlime.GetPlayer().Conquer(toConquer);

        SpendActions(1);
    }
Exemplo n.º 2
0
    public void Fusion(int actionSlimeId, int targetSlimeId)
    {
        RawSlime actionSlime       = FindSlimeById(actionSlimeId);
        RawSlime fusionTargetSlime = FindSlimeById(targetSlimeId);

        fusionTargetSlime.SetMass(actionSlime.GetMass() + fusionTargetSlime.GetMass());
        fusionTargetSlime.GetPlayer().RemoveSlime(actionSlime);

        SpendActions(1);
    }
Exemplo n.º 3
0
    public List <RawSlime> GetFusionTargets(RawSlime slime)
    {
        List <RawSlime> fusionSlimes = new List <RawSlime> ();

        foreach (TileData tile in matrix.getNeighbours(slime.GetTileData(), true))
        {
            RawSlime overSlime = tile.GetRawSlimeOnTop();
            if (overSlime != null && overSlime.GetPlayer() == slime.GetPlayer())
            {
                fusionSlimes.Add(overSlime);
            }
        }
        return(fusionSlimes);
    }
Exemplo n.º 4
0
    public List <AIRawSlimeAction> GetConquerActions(RawSlime slime)
    {
        // Devolvemos la accion de conquerir el terreno sobre el que esta esa slime
        List <AIRawSlimeAction> actions = new List <AIRawSlimeAction>();

        // Si no l'ha conquerit ja, pot conquerirla.
        if (!slime.GetPlayer().GetConqueredTiles().Contains(slime.GetActualTile()))
        {
            actions.Add(new AIRawSlimeAction(slime.GetId(), ActionType.CONQUER, slime.GetActualTile().getPosition()));
        }
        else if (slime.canGrow)
        {
            actions.Add(new AIRawSlimeAction(slime.GetId(), ActionType.EAT, slime.GetId()));
        }
        return(actions);
    }
Exemplo n.º 5
0
    public int GetDistanceToCloserEnemy(RawSlime slime)
    {
        int     distance = Int16.MaxValue;
        Vector2 myPos    = slime.GetActualTile().getPosition();

        foreach (RawPlayer p in players)
        {
            if (p != slime.GetPlayer())
            {
                foreach (RawSlime s in p.GetSlimes())
                {
                    Vector2 slPos = s.GetActualTile().getPosition();
                    distance = Mathf.Min(distance, Matrix.GetDistance(slPos, myPos));
                }
            }
        }
        return(distance);
    }
Exemplo n.º 6
0
    public List <RawSlime> GetSlimesInAttackRange(RawSlime slime)
    {
        List <RawSlime> canAttack = new List <RawSlime> ();
        Vector2         myPos     = slime.GetActualTile().getPosition();

        foreach (RawPlayer p in players)
        {
            if (p != slime.GetPlayer())
            {
                foreach (RawSlime s in p.GetSlimes())
                {
                    Vector2 slPos = s.GetActualTile().getPosition();
                    if (Matrix.GetDistance(slPos, myPos) <= slime.GetAttackRange())
                    {
                        canAttack.Add(s);
                    }
                }
            }
        }
        return(canAttack);
    }
Exemplo n.º 7
0
    public void Attack(int actionSlimeId, int targetSlimeId)
    {
        RawSlime actionSlime = FindSlimeById(actionSlimeId);
        RawSlime targetSlime = FindSlimeById(targetSlimeId);

        int damage = actionSlime.getDamage;

        if (actionSlime.changeMass((int)-actionSlime.GetMass() * actionSlime.attackDrain) <= 0)
        {
            actionSlime.GetPlayer().RemoveSlime(actionSlime);
        }
        if (targetSlime.changeMass((int)-damage * targetSlime.GetDamageReduction()) <= 0)
        {
            targetSlime.GetPlayer().RemoveSlime(targetSlime);

            /*Debug.Log("DEAD");
             * Debug.Log(targetSlime.GetPlayer());*/
        }

        SpendActions(1);
    }
Exemplo n.º 8
0
    public List <TileData> GetPossibleMovements(RawSlime slime)
    {
        List <TileData> moves = new List <TileData> ();

        if (matrix == null)
        {
            Debug.Log("MATRIX NULL");
        }
        if (slime == null)
        {
            Debug.Log("SLIME NULL");
        }
        if (slime.GetPlayer().statsCoreInfo == null)
        {
            Debug.Log("NULL");
        }
        Dictionary <TileData, List <TileData> > possible = matrix.possibleCoordinatesAndPath((int)slime.GetActualTile().getPosition().x, (int)slime.GetActualTile().getPosition().y, slime.GetMovementRange());

        foreach (TileData move in possible.Keys)
        {
            moves.Add(move);
        }
        return(moves);
    }