Esempio n. 1
0
    private bool MoveCharacter(Character activeChar, List <Character> myChars, Player enemyPlayer)
    {
        if (activeChar == null)
        {
            return(false);
        }

        List <Character> enemyChars = new List <Character>(enemyPlayer.characters.Values);
        GameState        gameState  = new GameState(myChars, enemyChars, htc.FindHex(activeChar.gameCharacter.position), activeChar);

        MiniAction miniAction = Search.DecideAction(gameState, htc);

        //Debug.Log(character.name+" will "+miniAction.type);

        switch (miniAction.type)
        {
        case "Move":
            HexTile  startTile = htc.FindHex(activeChar.gameCharacter.position);
            MiniMove move      = miniAction as MiniMove;

            List <int> path = Search.GreedySearch(startTile, move.Dest, htc);
            //Path ends on the tile you want to move to
            List <Vector3> moves = new List <Vector3>();
            if (path.Count > 0)
            {
                moves.Add(startTile.nexts[path[0]].Position);
                for (int i = 1; i < path.Count; i++)
                {
                    int neighbor = path[i];
                    moves.Add(htc.FindHex(moves[i - 1]).nexts[path[i]].Position);
                }
            }
            else
            {
                moves.Add(activeChar.gameCharacter.position);
            }

            //Debug.Log(activeChar.name+" is Moving to " + moves[moves.Count - 1]);
            //Action a = MoveActionFactory.getInstance().CreateAction(character, moves[moves.Count-1]);

            Action m = MoveActionFactory.getInstance().CreateAction(activeChar, moves.ToArray());
            GameSystem.CurrentGame().ExecuteCharacterAction(player, m);

            //StartCoroutine(Move(character.gameCharacter.gameObject, path, 0.5f));
            break;

        case "Attack":
            MiniAttack attack = miniAction as MiniAttack;
            Action     a      = AttackActionFactory.GetInstance().CreateAction(activeChar, attack.toAttack.gameCharacter.position);
            GameSystem.CurrentGame().ExecuteCharacterAction(player, a);
            break;

        case "AOEAttack":
            MiniAttack aoeAttack = miniAction as MiniAttack;
            Action     aoeA      = AttackActionFactory.GetInstance().CreateAction(activeChar, aoeAttack.attackLocation);
            GameSystem.CurrentGame().ExecuteCharacterAction(player, aoeA);
            break;
        }
        return(true);
    }
Esempio n. 2
0
        private static void RegisterActionFactoryRegistry(ContainerBuilder builder)
        {
            builder.Register <ActionFactoryRegistry>(c =>
            {
                var movementactionFactory = new MovementActionFactory();
                var lootActionFactory     = new LootActionFactory();
                var lootAllActionFactory  = new LootAllActionFactory();
                var attackActionFactory   = new AttackActionFactory();
                var consumeActionFactory  = new ConsumeActionFactory();

                var actionFactoryMap = new Dictionary <string, ActionFactory>
                {
                    { movementactionFactory.ActionName, movementactionFactory },
                    { lootActionFactory.ActionName, lootActionFactory },
                    { lootAllActionFactory.ActionName, lootAllActionFactory },
                    { attackActionFactory.ActionName, attackActionFactory },
                    { consumeActionFactory.ActionName, consumeActionFactory },
                };
                return(new ActionFactoryRegistry(actionFactoryMap));
            }).As <IActionFactoryRegistry>().SingleInstance();
        }
Esempio n. 3
0
 public static ActionFactory GetAttackFactory()
 {
     return(AttackActionFactory.GetInstance());
 }