示例#1
0
        public override Action TakeTurn()
        {
            Action lAction = null;

            //get input
            do
            {
                RogueKey lKeyPressed = Input.getKey(Console.ReadKey(true).Key);
                switch (Mode)
                {
                case PlayerMode.Normal:
                    lAction = NormalMode(lKeyPressed);
                    break;

                case PlayerMode.Interact:
                    lAction = InteractMode(lKeyPressed);
                    break;

                case PlayerMode.Inventory:
                    lAction = InventoryMode(lKeyPressed);
                    break;
                }
                base.level.ComputePlayerFOV();
                Display.printScreen(base.level, this.Mode);
            } while(lAction == null);

            return(lAction);
        }
示例#2
0
        public static Coordinate DirectionKeyToCoordinate(RogueKey aKeyPress)
        {
            Coordinate lReturn;

            lReturn.x = 0;
            lReturn.y = 0;
            switch (aKeyPress)
            {
            case RogueKey.SouthWest:
                lReturn.x = -1;
                lReturn.y = 1;
                break;

            case RogueKey.South:
                lReturn.y = 1;
                break;

            case RogueKey.SouthEast:
                lReturn.x = 1;
                lReturn.y = 1;
                break;

            case RogueKey.West:
                lReturn.x = -1;
                break;

            case RogueKey.East:
                lReturn.x = 1;
                break;

            case RogueKey.NorthWest:
                lReturn.x = -1;
                lReturn.y = -1;
                break;

            case RogueKey.North:
                lReturn.y = -1;
                break;

            case RogueKey.NorthEast:
                lReturn.x = 1;
                lReturn.y = -1;
                break;
            }
            return(lReturn);
        }
示例#3
0
        public static bool IsDirectionKey(RogueKey aKeyPress)
        {
            bool lReturn = false;

            if ((aKeyPress == RogueKey.SouthWest) ||
                (aKeyPress == RogueKey.South) ||
                (aKeyPress == RogueKey.SouthEast) ||
                (aKeyPress == RogueKey.West) ||
                (aKeyPress == RogueKey.East) ||
                (aKeyPress == RogueKey.NorthWest) ||
                (aKeyPress == RogueKey.North) ||
                (aKeyPress == RogueKey.NorthEast))
            {
                lReturn = true;
            }
            return(lReturn);
        }
示例#4
0
        Action InteractMode(RogueKey aKeyPress)
        {
            Action lAction = null;

            if (Input.IsDirectionKey(aKeyPress))
            {
                this.Selection = Input.DirectionKeyToCoordinate(aKeyPress);
            }
            else
            {
                switch (aKeyPress)
                {
                case RogueKey.ChangeMode:
                    Mode             = PlayerMode.Inventory;
                    this.Selection.x = 0;
                    this.Selection.y = 0;
                    break;

                case RogueKey.Cancel:
                    Mode             = PlayerMode.Normal;
                    this.Selection.x = 0;
                    this.Selection.y = 0;
                    break;

                case RogueKey.Select:
                    if (this.level.ActorGrid.GetItem(this.pos + this.Selection) != null)
                    {
                        lAction = new MeleeAttackAction(this, this.level.ActorGrid.GetItem(this.pos + this.Selection));
                    }
                    else if (this.level.ObjectGrid.GetItem(this.pos + this.Selection) != null)
                    {
                        lAction = this.level.ObjectGrid.GetItem(this.pos + this.Selection).DefaultAction(this);
                    }
                    else if (this.level.ItemGrid.GetItem(this.pos + this.Selection) != null)
                    {
                        lAction = new PickUpAction(this, this.level.ItemGrid.GetItem(this.pos + this.Selection));
                    }
                    Mode             = PlayerMode.Normal;
                    this.Selection.x = 0;
                    this.Selection.y = 0;
                    break;
                }
            }
            return(lAction);
        }
示例#5
0
        public static Direction DirectionKeyToDirection(RogueKey aKeyPress)
        {
            Direction lReturn = Direction.NA;

            switch (aKeyPress)
            {
            case RogueKey.SouthWest:
                lReturn = Direction.SouthWest;
                break;

            case RogueKey.South:
                lReturn = Direction.South;
                break;

            case RogueKey.SouthEast:
                lReturn = Direction.SouthEast;
                break;

            case RogueKey.West:
                lReturn = Direction.West;
                break;

            case RogueKey.East:
                lReturn = Direction.East;
                break;

            case RogueKey.NorthWest:
                lReturn = Direction.NorthWest;
                break;

            case RogueKey.North:
                lReturn = Direction.North;
                break;

            case RogueKey.NorthEast:
                lReturn = Direction.NorthEast;
                break;
            }
            return(lReturn);
        }
示例#6
0
        Action NormalMode(RogueKey aKeyPress)
        {
            Action lAction = null;

            if (Input.IsDirectionKey(aKeyPress))
            {
                //deal with direction key press
                lAction = new MoveAction(this, Input.DirectionKeyToDirection(aKeyPress));
            }
            else
            {
                switch (aKeyPress)
                {
                case RogueKey.ChangeMode:
                    Mode = PlayerMode.Interact;
                    break;

                case RogueKey.Cancel:
                    break;
                }
            }
            return(lAction);
        }
示例#7
0
        Action InventoryMode(RogueKey aKeyPress)
        {
            Action lAction = null;

            switch (aKeyPress)
            {
            case RogueKey.ChangeMode:
                Mode             = PlayerMode.Normal;
                this.Selection.x = 0;
                this.Selection.y = 0;
                break;

            case RogueKey.Cancel:
                Mode             = PlayerMode.Normal;
                this.Selection.x = 0;
                this.Selection.y = 0;
                break;

            case RogueKey.North:
                if (this.Inventory != null && this.Inventory.Count > 0 && InvSelection > 0)
                {
                    InvSelection--;
                }
                break;

            case RogueKey.South:
                if (this.Inventory != null && InvSelection < (this.Inventory.Count - 1))
                {
                    InvSelection++;
                }
                break;

            case RogueKey.Select:
                if (this.Inventory != null && this.Inventory.Count >= 0 && InvSelection < this.Inventory.Count)
                {
                    Item lItem   = this.Inventory [InvSelection];
                    bool lResult = true;
                    if (lItem.EquipTo == null)
                    {
                        lAction = new ConsumeAction(this, lItem);
                    }
                    else
                    {
                        lResult = base.Equip(lItem);
                    }
                    if (lResult)
                    {
                        if (InvSelection > 0)
                        {
                            InvSelection--;
                        }
                        else
                        {
                            InvSelection = 0;
                        }
                    }
                }
                break;
            }

            return(lAction);
        }