Example #1
0
        public void Initialize()
        {
            player1 = new PlayerClass();
            player2 = new PlayerClass();
            player3 = new PlayerClass();
            player4 = new PlayerClass();

            returnState = null;

            animations = new List <Animation>();

            player1.title = "P1";
            player2.title = "P2";
            player3.title = "P3";
            player4.title = "P4";

            player1.onPlayerKilled += new PlayerClass.PlayerKilledHandler(playerKilled);
            player2.onPlayerKilled += new PlayerClass.PlayerKilledHandler(playerKilled);
            player3.onPlayerKilled += new PlayerClass.PlayerKilledHandler(playerKilled);
            player4.onPlayerKilled += new PlayerClass.PlayerKilledHandler(playerKilled);

            currPlayer   = PlayerKeys.Player1;
            paused       = false;
            playerPaused = 0;
            AudioManager.TriggerBattle();
        }
Example #2
0
    public KeyCode GetPlayerInputKeyCode(PlayerKeys playerKey, int playerNumber)
    {
        KeyCode key;

        switch (playerKey)
        {
        case PlayerKeys.Left:
            key = leftMove[playerNumber - 1];
            break;

        case PlayerKeys.Right:
            key = leftMove[playerNumber - 1];
            break;

        case PlayerKeys.Jump:
            key = jump[playerNumber - 1];
            break;

        case PlayerKeys.Action:
            key = action[playerNumber - 1];
            break;

        default:
            key = KeyCode.None;
            break;
        }
        return(key);
    }
Example #3
0
    public KeyCode RandomiseOnePlayerKey(PlayerKeys playerKey, int playerNumber)
    {
        ClearOnePlayerKey(playerKey, playerNumber - 1);
        KeyCode newKeyCode = GetRandomUnusedKey(playerNumber);

        switch (playerKey)
        {
        case PlayerKeys.Left:
            leftMove[playerNumber - 1] = newKeyCode;
            break;

        case PlayerKeys.Right:
            rightMove[playerNumber - 1] = newKeyCode;
            break;

        case PlayerKeys.Jump:
            jump[playerNumber - 1] = newKeyCode;
            break;

        case PlayerKeys.Action:
            action[playerNumber - 1] = newKeyCode;
            break;

        default:
            break;
        }
        UpdateAllUIKeys();
        return(newKeyCode);
    }
Example #4
0
    int keys()
    {
        PlayerKeys pkeys = GetComponent <PlayerKeys>();

        numKeys = pkeys.numKeys;
        return(numKeys);
    }
Example #5
0
    //on awake we intialise the player settings which is the default values and also set up the singleton
    void Awake()
    {
        //audioClass = new AudioClass();
        //audioClass.InitialiseAudioClass();
        gameObject.AddComponent <AudioClass>();
        playerdata = new PlayerData();
        for (int i = 0; i < playerSetting.Length; i++)
        {
            playerSetting[i] = new PlayerKeys();
            playerSetting[i].IntialiseValues();
        }
        GameObject gm = GameObject.Find("GameManager");

        if (gm != null)
        {
            DontDestroyOnLoad(gm.gameObject);
            _instance = gm.GetComponent <MenuScript>();
        }
        backToMenu = false;
        IntialiseAndSetScene();
        LoadPlayerData();
        //Set the max level by the player data
        maxLevel       = playerdata.getCurrentLevel();
        whichPlayerKey = 0;
        hoveringOver   = eventSystem.GetComponent <EventSystem>().currentSelectedGameObject;
    }
Example #6
0
        public bool IsKeyHold(PlayerKeys key)
        {
            switch (key)
            {
            case PlayerKeys.Up:
                return(currks.IsKeyDown(Keys.Up) || currgs.IsButtonDown(Buttons.DPadUp));

            case PlayerKeys.Down:
                return(currks.IsKeyDown(Keys.Down) || currgs.IsButtonDown(Buttons.DPadDown));

            case PlayerKeys.Left:
                return(currks.IsKeyDown(Keys.Left) || currgs.IsButtonDown(Buttons.DPadLeft));

            case PlayerKeys.Right:
                return(currks.IsKeyDown(Keys.Right) || currgs.IsButtonDown(Buttons.DPadRight));

            case PlayerKeys.Interact:
                return(currks.IsKeyDown(Keys.Z) || currgs.IsButtonDown(Buttons.A));

            case PlayerKeys.Back:
                return(currks.IsKeyDown(Keys.X) || currgs.IsButtonDown(Buttons.B));

            case PlayerKeys.Pause:
                return(currks.IsKeyDown(Keys.C) || currgs.IsButtonDown(Buttons.Start));

            default:
                return(false);
            }
        }
Example #7
0
        public bool IsKeyPress(PlayerKeys key)
        {
            switch (key)
            {
            case PlayerKeys.Up:
                return(_keyPress(Keys.Up) || _btnPress(Buttons.DPadUp));

            case PlayerKeys.Down:
                return(_keyPress(Keys.Down) || _btnPress(Buttons.DPadDown));

            case PlayerKeys.Left:
                return(_keyPress(Keys.Left) || _btnPress(Buttons.DPadLeft));

            case PlayerKeys.Right:
                return(_keyPress(Keys.Right) || _btnPress(Buttons.DPadRight));

            case PlayerKeys.Interact:
                return(_keyPress(Keys.Z) || _btnPress(Buttons.A));

            case PlayerKeys.Back:
                return(_keyPress(Keys.X) || _btnPress(Buttons.B));

            case PlayerKeys.Pause:
                return(_keyPress(Keys.C) || _btnPress(Buttons.Start));

            default:
                return(false);
            }
        }
Example #8
0
 public void SetPlayerKeys(EKeyset pKeyset, PlayerKeys pKeys)
 {
     SetPlayerActionKey(pKeyset, EActionKey.Up, pKeys.moveUp);
     SetPlayerActionKey(pKeyset, EActionKey.Right, pKeys.moveRight);
     SetPlayerActionKey(pKeyset, EActionKey.Down, pKeys.moveDown);
     SetPlayerActionKey(pKeyset, EActionKey.Left, pKeys.moveLeft);
     SetPlayerActionKey(pKeyset, EActionKey.Swap, pKeys.swapWeapon);
     SetPlayerActionKey(pKeyset, EActionKey.Use, pKeys.useWeapon);
 }
    public override bool getKey(PlayerKeys key)
    {
        /*if ( key == PlayerKeys.RUN )
        {
            return true;
        }*/

        return false;
    }
    public override bool getKey(PlayerKeys key)
    {
        /*if ( key == PlayerKeys.RUN )
         * {
         *      return true;
         * }*/

        return(false);
    }
Example #11
0
    public bool useKey(KeyCode pressedKey)
    {
        PlayerKeys checkingKeyProperties = usedKeys [pressedKey];

        if (checkingKeyProperties.Pressed && !checkingKeyProperties.Used)
        {
            usedKeys [pressedKey] = new PlayerKeys(checkingKeyProperties.Pressed, true);
            return(true);
        }
        return(false);
    }
Example #12
0
    public void Init(PlayerInitInfo pPlayerInfo)
    {
        //AIs dont use input
        //assign keys to my players
        if (pPlayerInfo.PlayerType == EPlayerType.AI || !pPlayerInfo.IsItMe())
        {
            //todo: send message to remote player
            return;
        }
        if (PlatformManager.GetPlatform() == EPlatform.PC)       // && !DebugData.TestMobileInput)
        {
            if (pPlayerInfo.Keyset == EKeyset.None)
            {
                Debug.LogError($"{player} has no keyset");
                switch (pPlayerInfo.Number)
                {
                case 1:
                    pPlayerInfo.Keyset = EKeyset.KeysetA;
                    break;

                case 2:
                    pPlayerInfo.Keyset = EKeyset.KeysetB;
                    break;

                case 3:
                    pPlayerInfo.Keyset = EKeyset.KeysetC;
                    break;

                case 4:
                    pPlayerInfo.Keyset = EKeyset.KeysetD;
                    break;

                default:
                    pPlayerInfo.Keyset = EKeyset.KeysetA;
                    break;
                }
            }

            keys = brainiacs.PlayerKeysManager.GetPlayerKeys(pPlayerInfo.Keyset);
        }

        if (PlatformManager.IsMobile())
        {
            MobileInput mobileInput = game.MobileInput;
            mobileInput.btnShoot.OnPressedAction    = () => weapon.UseWeapon();
            mobileInput.btnShoot.OnPointerUpAction  = () => weapon.StopUseWeapon();
            mobileInput.btnSwap.OnPointerDownAction = () => weapon.SwapWeapon();

            mobileInput.moveJoystick.OnUpdateDirection += HandleMoveJoystick;
        }
        isInited = true;
    }
Example #13
0
    internal void UpdateKeySet(EKeyset pSet, PlayerKeys pPlayerKeys)
    {
        if (!keys.ContainsKey(pSet))
        {
            keys.Add(pSet, pPlayerKeys);
        }
        else
        {
            keys[pSet] = pPlayerKeys;
        }

        brainiacs.PlayerPrefs.SetPlayerKeys(pSet, pPlayerKeys);
    }
Example #14
0
 private void OnCollisionEnter2D(Collision2D other)
 {
     if (other.gameObject.CompareTag("Player"))
     {
         PlayerKeys keys = other.gameObject.GetComponent <PlayerKeys>();
         if (keys.HasKey())
         {
             keys.keys            -= 1;
             this.collider.enabled = false;
             this.renderer.sprite  = this.shadow;
         }
     }
 }
    public override bool getKeyDown(PlayerKeys key)
    {
        if (key == PlayerKeys.JUMP)
        {
            return(listButtons[((int)key)].wasPressed());
        }

        if (key == PlayerKeys.ATTACK)
        {
            return(listButtons[((int)key)].wasPressed());
        }

        return(false);
    }
Example #16
0
    private void OnTriggerEnter2D(Collider2D collision)
    {
        if (collision.gameObject == GameMaster.GetPlayer())
        {
            if (m_pickupFX != null)
            {
                GameMaster.GetAudioManager().CreateAndPlayAudioObject(m_pickupFX);
            }

            PlayerKeys playerKeys = collision.gameObject.GetComponent <PlayerKeys>();
            playerKeys.RegisterKey(m_id, m_color);
            Destroy(gameObject);
        }
    }
Example #17
0
    private new void Awake()
    {
        btnSettingsBack.onClick.AddListener(mainMenu.OnBtnBack);

        PlayerKeys keysA = brainiacs.PlayerPrefs.GetPlayerKeys(EKeyset.KeysetA);
        PlayerKeys keysB = brainiacs.PlayerPrefs.GetPlayerKeys(EKeyset.KeysetB);
        PlayerKeys keysC = brainiacs.PlayerPrefs.GetPlayerKeys(EKeyset.KeysetC);
        PlayerKeys keysD = brainiacs.PlayerPrefs.GetPlayerKeys(EKeyset.KeysetD);

        keySetA.Init(EKeyset.KeysetA, keysA);
        keySetB.Init(EKeyset.KeysetB, keysB);
        keySetC.Init(EKeyset.KeysetC, keysC);
        keySetD.Init(EKeyset.KeysetD, keysD);
    }
Example #18
0
    private void OnTriggerEnter2D(Collider2D collision)
    {
        if (collision.gameObject == GameMaster.GetPlayer())
        {
            PlayerKeys playerKeys = collision.gameObject.GetComponent <PlayerKeys>();
            if (playerKeys.HasKey(m_endGameKeyId))
            {
                collision.gameObject.GetComponent <PlayerEndGame>().CompleteGame();

                playerKeys.RemoveKey(m_endGameKeyId);
                GetComponent <Fader>().StartFade();
            }
        }
    }
Example #19
0
    void OnTriggerEnter2D(Collider2D other)
    {
        PlayerKeys pkeys = other.GetComponent <PlayerKeys>();

        if (pkeys != null)
        {
            if (gather == 0)
            {
                pkeys.AddKey();
                Destroy(gameObject);
                gather++;
            }
        }
    }
    public override bool getKeyDown(PlayerKeys key)
    {
        if ( key == PlayerKeys.JUMP )
        {
            return listButtons[((int)key)].wasPressed();
        }

        if ( key == PlayerKeys.ATTACK )
        {
            return listButtons[((int)key)].wasPressed();
        }

        return false;
    }
Example #21
0
    private void OnTriggerEnter2D(Collider2D collision)
    {
        if (collision.gameObject == GameMaster.GetPlayer())
        {
            PlayerKeys playerKeys = collision.gameObject.GetComponent <PlayerKeys>();
            if (playerKeys.HasKey(m_id))
            {
                playerKeys.RemoveKey(m_id);
                GetComponent <Fader>().StartFade();

                if (m_openFX != null)
                {
                    GameMaster.GetAudioManager().CreateAndPlayAudioObject(m_openFX);
                }
            }
        }
    }
Example #22
0
        public override void DoCheckFlee()
        {
            int numAttackers = GetAttackerCount();

            // Less then specified hp or mana plus 10%, and more then 1 attacker?
            if (_ak.PlayerHealth < profile.GetInteger("FleeBelowHealth") + 10 &&
                numAttackers > 1)
            {
                // Yes? RUN FOREST RUN !
                AddMessage("Run away!");
                Action = BotAction.Flee;
                PlayerKeys.Sprint(KeyDirection.KeyUpDown);

                ActionQueue.Clear();
                ActionQueue.Enqueue(BotAction.Rest);
                return;
            }

            //Just one attacker, and below health at which we should run away?
            if (_ak.PlayerHealth < profile.GetInteger("FleeBelowHealth"))
            {
                // Our attacker has more HP then us?
                if (_ak.TargetIndex > 0 && _ak.PlayerHealth < _ak.TargetObject.Health)
                {
                    // Yes? RUN FOREST RUN !
                    AddMessage("Run away!");
                    Action = BotAction.Flee;
                    PlayerKeys.Sprint(KeyDirection.KeyUpDown);

                    ActionQueue.Clear();
                    ActionQueue.Enqueue(BotAction.Rest);
                    return;
                }
            }

            // Check if we have a next action
            if (ActionQueue.Count == 0)
            {
                throw new Exception("No action in ActionQueue");
            }

            // Next Action
            Action = ActionQueue.Dequeue();
        }
Example #23
0
    public PlayerKeys GetPlayerKeys(EKeyset pKeyset)
    {
        KeyCode up    = PlayerPrefsX.GetKeysetKey(pKeyset, EActionKey.Up);
        KeyCode right = PlayerPrefsX.GetKeysetKey(pKeyset, EActionKey.Right);
        KeyCode down  = PlayerPrefsX.GetKeysetKey(pKeyset, EActionKey.Down);
        KeyCode left  = PlayerPrefsX.GetKeysetKey(pKeyset, EActionKey.Left);

        KeyCode swap = PlayerPrefsX.GetKeysetKey(pKeyset, EActionKey.Swap);
        KeyCode use  = PlayerPrefsX.GetKeysetKey(pKeyset, EActionKey.Use);

        PlayerKeys keys = new PlayerKeys(up, right, down, left, swap, use);

        if (!keys.IsValid())
        {
            Debug.LogError($"{pKeyset} not set. is this first run?");
            keys = new PlayerKeys(pKeyset);
        }

        return(keys);
    }
Example #24
0
    public void Init(EKeyset pKeyset, PlayerKeys pPlayerKeys)
    {
        Keyset      = pKeyset;
        header.text = Keyset.ToString();

        keyUp.OnKeySet    += OnAnyKeySet;
        keyRight.OnKeySet += OnAnyKeySet;
        keyDown.OnKeySet  += OnAnyKeySet;
        keyLeft.OnKeySet  += OnAnyKeySet;
        keySwap.OnKeySet  += OnAnyKeySet;
        keyUse.OnKeySet   += OnAnyKeySet;

        keyUp.SetKey(pPlayerKeys.moveUp);
        keyRight.SetKey(pPlayerKeys.moveRight);
        keyDown.SetKey(pPlayerKeys.moveDown);
        keyLeft.SetKey(pPlayerKeys.moveLeft);

        keySwap.SetKey(pPlayerKeys.swapWeapon);
        keyUse.SetKey(pPlayerKeys.useWeapon);
    }
Example #25
0
    public void ClearOnePlayerKey(PlayerKeys playerKey, int playerNumber)
    {
        switch (playerKey)
        {
        case PlayerKeys.Left:
            if (!unusedKeysList.Contains(leftMove[playerNumber]) && leftMove[playerNumber] != KeyCode.None)
            {
                unusedKeysList.Add(leftMove[playerNumber]);
            }
            leftMove[playerNumber] = KeyCode.None;
            break;

        case PlayerKeys.Right:
            if (!unusedKeysList.Contains(rightMove[playerNumber]) && rightMove[playerNumber] != KeyCode.None)
            {
                unusedKeysList.Add(rightMove[playerNumber]);
            }
            rightMove[playerNumber] = KeyCode.None;
            break;

        case PlayerKeys.Jump:
            if (!unusedKeysList.Contains(jump[playerNumber]) && jump[playerNumber] != KeyCode.None)
            {
                unusedKeysList.Add(jump[playerNumber]);
            }
            jump[playerNumber] = KeyCode.None;
            break;

        case PlayerKeys.Action:
            if (!unusedKeysList.Contains(action[playerNumber]) && action[playerNumber] != KeyCode.None)
            {
                unusedKeysList.Add(action[playerNumber]);
            }
            action[playerNumber] = KeyCode.None;
            break;

        default:
            break;
        }
    }
Example #26
0
    void Init()
    {
        if (Player == 1)
        {
            Keys = CPlayerKeys.Player1;
        }
        else if (Player == 2)
        {
            Keys = CPlayerKeys.Player2;
        }

        Rb = GetComponent <Rigidbody>();
        Rb.centerOfMass = Center;

        Weapon.AttackKey   = Keys.AttackKey;
        leftWheel.UpKey    = Keys.LeftWhealUpKey;
        leftWheel.DownKey  = Keys.LeftWhealDownKey;
        RightWheel.UpKey   = Keys.RightWhealUpKey;
        RightWheel.DownKey = Keys.RightWhealDownKey;

        Weapon.MainBody = this;
    }
Example #27
0
    void Update()
    {
        ArrayList modifiedButtons = new ArrayList();

        foreach (KeyValuePair <KeyCode, PlayerKeys> entry in usedKeys)
        {
            KeyCode    checkKey        = entry.Key;
            PlayerKeys checkProperties = entry.Value;

            if ((Input.GetKeyDown(checkKey) && !checkProperties.Pressed) ||
                (Input.GetKeyUp(entry.Key) && checkProperties.Pressed))
            {
                modifiedButtons.Add(checkKey);
            }
        }

        foreach (KeyCode modifiedKey in modifiedButtons)
        {
            PlayerKeys checkProperties = usedKeys[modifiedKey];
            bool       isPressed       = checkProperties.Pressed ? false : true;
            usedKeys[modifiedKey] = new PlayerKeys(isPressed, false);
        }
    }
Example #28
0
        public override void DoRangedFight()
        {
            if (_ak.TargetIndex < 1 || _ak.get_IsMobDead(_ak.TargetIndex))
            {
                AddMessage("Target Dead");
                // Target is lost, check for agro
                Action = BotAction.CheckAgro;

                ActionQueue.Clear();
                ActionQueue.Enqueue(BotAction.Loot);
                ActionQueue.Enqueue(BotAction.CheckAgro);

                playerShooting = false;
                playerSwinging = false;
                NumKilled++;
                AddMessage(string.Format("==> Number Killed {0} <==", NumKilled));
                nextRanged    = eRangedFights.Crit;
                nCountFight   = 0;
                currentTarget = 0;
                //in case we have bow drawn, make sure to put it away so we can
                //use crit shot for next kill even if we dont run anywhere
                UseQbar(profile.GetString("Scout.FightMeleeWeaponQ"), profile.GetString("Scout.FightMeleeWeaponKey"));

                return;
            }

            //just in case
            _ak.StopRunning();

            Action = BotAction.CheckFlee;
            ActionQueue.Clear();
            ActionQueue.Enqueue(BotAction.RangedFight);

            //if target close enough to switch to melee fight, do it
            //done before cooldown check since we can cast melee range spells immediately
            if (_ak.TargetIndex > 0 && DistanceToMob(_ak.TargetIndex) < profile.GetFloat("MinimumRangedAttackDistance"))
            {
                Action = BotAction.MeleeFight;

                //face target
                PlayerKeys.Face(KeyDirection.KeyUpDown);

                //switch to melee weapon
                UseQbar(profile.GetString("Scout.FightMeleeWeaponQ"), profile.GetString("Scout.FightMeleeWeaponKey"));

                return;
            }

            //check if we targeted something in a dungeon we cant get see, "not in line of sight"
            if (bNoLineOfSight)
            {
                if (_ak.TargetIndex > 0)
                {
                    IgnoreThis(_ak.TargetIndex);
                    ActionQueue.Clear();
                    ActionQueue.Enqueue(BotAction.FindTarget);
                    //lets clear the stuff we use to test for unfightable targets
                    currentTarget = 0;
                    AddMessage("In Ranged Fight, no LOS, added to bad target list");
                    return;
                }
            }

            //check if this is a new fight, so we can store our mob
            if (currentTarget < 1 && _ak.TargetIndex > 0)
            {
                currentTarget = _ak.TargetIndex;
                nextRanged    = eRangedFights.Crit;
//				playerShooting = false;
//				playerSwinging = false;
            }
            //Got out of range somehow?
            if (_ak.TargetIndex > 0 && DistanceToMob(_ak.TargetIndex) > profile.GetFloat("MaximumRangedAttackDistance"))
            {
                AddMessage("Target out of range, moving closer");

                //for some reason we need to break auto face
                //before moveto will work right
                PlayerKeys.TurnLeft(KeyDirection.KeyDown);
                Thread.Sleep(25);
                PlayerKeys.TurnLeft(KeyDirection.KeyUp);

                Action = BotAction.GetInRange;
                ActionQueue.Clear();
                ActionQueue.Enqueue(BotAction.RangedFight);

                return;
            }

            //nothing more to do if still shooting
            if (playerShooting || !cooldowns.IsReady("FightDelay"))
            {
                return;
            }

            if (_ak.PlayerLeftHand != AutoKillerScript.WeaponSlots.Ranged)
            {
                UseQbar(profile.GetString("Scout.FightRangedBowQ"), profile.GetString("Scout.FightRangedBowKey"));
            }

            if (nextRanged == eRangedFights.Crit)
            {
                AddMessage(string.Format("Fight Starting at distance: {0}", DistanceToMob(_ak.TargetIndex)));
            }

            //if this is our first ranged fight, do crit shot
            if (_ak.TargetIndex > 0 &&
                nextRanged == eRangedFights.Crit &&
                !playerShooting)
            {
                // Do the crit shot
                UseQbar(profile.GetString("Scout.FightRangedCritQ"), profile.GetString("Scout.FightRangedCritKey"));

                //release and reload
                UseQbar(profile.GetString("Scout.FightRangedBowQ"), profile.GetString("Scout.FightRangedBowKey"));
                UseQbar(profile.GetString("Scout.FightRangedBowQ"), profile.GetString("Scout.FightRangedBowKey"));

                playerShooting = true;
                nextRanged     = eRangedFights.Bow;
                cooldowns.SetTime("FightDelay");
                nCountFight++;

                return;
            }

            if (_ak.TargetIndex > 0 &&                                          //make sure we have a target
                nextRanged == eRangedFights.Bow &&                              //not pull spell
                !playerShooting)                                                //not casting anything
            {
                AddMessage("Regular bow shot - Range " + DistanceToMob(_ak.TargetIndex).ToString());

                //release and reload
                UseQbar(profile.GetString("Scout.FightRangedBowQ"), profile.GetString("Scout.FightRangedBowKey"));
                UseQbar(profile.GetString("Scout.FightRangedBowQ"), profile.GetString("Scout.FightRangedBowKey"));

                playerShooting = true;
                nextRanged     = eRangedFights.Bow;
                cooldowns.SetTime("FightDelay");
                nCountFight++;
            }
        }
 public virtual bool getKeyDown(PlayerKeys key)
 {
     return Input.GetKeyDown(listKeys[(int)key]);
 }
Example #30
0
        public void Update(GameTime gameTime)
        {
            KeyboardState currState = Keyboard.GetState();


            if (paused)
            {
                if (currState.IsKeyDown(Keys.P) && currState != oldState && playerPaused == (int)currPlayer)
                {
                    paused   = false;
                    oldState = currState;
                }
                foreach (PlayerIndex x in Enum.GetValues(typeof(PlayerIndex)))
                {
                    if (playerPaused == (int)x && GamePad.GetState(x).IsButtonDown(Buttons.Start) && !oldStartState[(int)x])
                    {
                        paused = false;
                        oldStartState[(int)x] = GamePad.GetState(x).IsButtonDown(Buttons.Start);
                    }
                }
            }

            if (!paused)
            {
                if (currState.IsKeyDown(Keys.P) && currState != oldState)
                {
                    paused       = true;
                    oldState     = currState;
                    playerPaused = (int)currPlayer;
                }
                foreach (PlayerIndex x in Enum.GetValues(typeof(PlayerIndex)))
                {
                    if (GamePad.GetState(x).IsButtonDown(Buttons.Start) && !oldStartState[(int)x])
                    {
                        paused       = true;
                        playerPaused = (int)x;
                    }
                }
            }

            if (paused)
            {
                oldState         = currState;
                oldStartState[0] = GamePad.GetState(PlayerIndex.One).IsButtonDown(Buttons.Start);
                oldStartState[1] = GamePad.GetState(PlayerIndex.Two).IsButtonDown(Buttons.Start);
                oldStartState[2] = GamePad.GetState(PlayerIndex.Three).IsButtonDown(Buttons.Start);
                oldStartState[3] = GamePad.GetState(PlayerIndex.Four).IsButtonDown(Buttons.Start);

                GamePadState p1 = GamePad.GetState(PlayerIndex.One);
                if (p1.IsButtonDown(Buttons.LeftTrigger) && p1.IsButtonDown(Buttons.RightTrigger) && p1.IsButtonDown(Buttons.LeftShoulder) && p1.IsButtonDown(Buttons.RightShoulder))
                {
                    returnState = levelSelect;
                }
                GamePadState p2 = GamePad.GetState(PlayerIndex.Two);
                if (p2.IsButtonDown(Buttons.LeftTrigger) && p2.IsButtonDown(Buttons.RightTrigger) && p2.IsButtonDown(Buttons.LeftShoulder) && p2.IsButtonDown(Buttons.RightShoulder))
                {
                    returnState = levelSelect;
                }
                GamePadState p3 = GamePad.GetState(PlayerIndex.Three);
                if (p3.IsButtonDown(Buttons.LeftTrigger) && p3.IsButtonDown(Buttons.RightTrigger) && p3.IsButtonDown(Buttons.LeftShoulder) && p3.IsButtonDown(Buttons.RightShoulder))
                {
                    returnState = levelSelect;
                }
                GamePadState p4 = GamePad.GetState(PlayerIndex.Four);
                if (p4.IsButtonDown(Buttons.LeftTrigger) && p4.IsButtonDown(Buttons.RightTrigger) && p4.IsButtonDown(Buttons.LeftShoulder) && p4.IsButtonDown(Buttons.RightShoulder))
                {
                    returnState = levelSelect;
                }
                if (Keyboard.GetState().IsKeyDown(Keys.R))
                {
                    returnState = levelSelect;
                }
                return;
            }

            /* Press TAB to change player if using keyboard. *** For Testing Purposes Only ***
             * If you hold down a key while pressing TAB, the previous player will continue to do that same action
             * over and over again until you tab to that player again.
             * (It is kinda amusing, but could be useful for collison testing) */
            if (currState.IsKeyDown(Keys.Tab) && oldState != currState)
            {
                switch ((int)currPlayer)
                {
                case 0:
                    currPlayer = PlayerKeys.Player2;
                    break;

                case 1:
                    currPlayer = PlayerKeys.Player3;
                    break;

                case 2:
                    currPlayer = PlayerKeys.Player4;
                    break;

                case 3:
                    currPlayer = PlayerKeys.allPlayers;
                    break;

                case 4:
                    currPlayer = PlayerKeys.Player1;
                    break;
                }
                //Switches to the next player
            }
            if (currPlayer == PlayerKeys.Player1)
            {
                player1State = Keyboard.GetState();
            }

            if (currPlayer == PlayerKeys.Player2)
            {
                player2State = Keyboard.GetState();
            }

            if (currPlayer == PlayerKeys.Player3)
            {
                player3State = Keyboard.GetState();
            }
            if (currPlayer == PlayerKeys.Player4)
            {
                player4State = Keyboard.GetState();
            }

            if (currPlayer == PlayerKeys.allPlayers)
            {
                player1State = Keyboard.GetState();
                player2State = Keyboard.GetState();
                player3State = Keyboard.GetState();
                player4State = Keyboard.GetState();
            }
            //End of TAB code. Can now only control one player at a time using keyboard.
            player1.Update(player1State, GamePad.GetState(PlayerIndex.One), gameTime);
            player2.Update(player2State, GamePad.GetState(PlayerIndex.Two), gameTime);
            player3.Update(player3State, GamePad.GetState(PlayerIndex.Three), gameTime);
            player4.Update(player4State, GamePad.GetState(PlayerIndex.Four), gameTime);
            foreach (SpearClass sp in spears)
            {
                if (sp.spearOwner == player1)
                {
                    sp.Update(player1State, GamePad.GetState(PlayerIndex.One));
                }

                else if (sp.spearOwner == player2)
                {
                    sp.Update(player2State, GamePad.GetState(PlayerIndex.Two));
                }
                else if (sp.spearOwner == player3)
                {
                    sp.Update(player3State, GamePad.GetState(PlayerIndex.Three));
                }
                else if (sp.spearOwner == player4)
                {
                    sp.Update(player4State, GamePad.GetState(PlayerIndex.Four));
                }
                else
                {
                    KeyboardState fakestate = new KeyboardState();
                    GamePadState  faker     = new GamePadState();
                    sp.Update(fakestate, faker);
                }
            }
            oldState = currState;

            oldStartState[0] = GamePad.GetState(PlayerIndex.One).IsButtonDown(Buttons.Start);
            oldStartState[1] = GamePad.GetState(PlayerIndex.Two).IsButtonDown(Buttons.Start);
            oldStartState[2] = GamePad.GetState(PlayerIndex.Three).IsButtonDown(Buttons.Start);
            oldStartState[3] = GamePad.GetState(PlayerIndex.Four).IsButtonDown(Buttons.Start);
            //If a timer is running, decrement here

            timeElapsed = (float)gameTime.ElapsedGameTime.TotalSeconds;
            if (roundReset > 0)
            {
                roundReset -= timeElapsed;
                if (roundReset < 0)
                {
                    if (ultimateWin > 0)
                    {
                        returnState = Win;
                        return;
                    }
                    else
                    {
                        resetMap();
                    }
                }
            }

            //Update animations
            for (int i = 0; i < animations.Count; i++)
            {
                animations[i].Update(gameTime);
            }
        }
Example #31
0
        public void Update(GameTime gameTime)
        {
            KeyboardState currState = Keyboard.GetState();

            if(paused)
            {
                if (currState.IsKeyDown(Keys.P) && currState != oldState && playerPaused == (int)currPlayer)
                {
                    paused = false;
                    oldState = currState;
                }
                foreach (PlayerIndex x in Enum.GetValues(typeof(PlayerIndex)))
                {
                    if (playerPaused == (int)x && GamePad.GetState(x).IsButtonDown(Buttons.Start) && !oldStartState[(int)x])
                    {
                        paused = false;
                        oldStartState[(int)x] = GamePad.GetState(x).IsButtonDown(Buttons.Start);
                    }
                }
            }

            if (!paused)
            {
                if (currState.IsKeyDown(Keys.P) && currState != oldState)
                {
                    paused = true;
                    oldState = currState;
                    playerPaused = (int)currPlayer;
                }
                foreach (PlayerIndex x in Enum.GetValues(typeof(PlayerIndex)))
                {
                    if (GamePad.GetState(x).IsButtonDown(Buttons.Start) && !oldStartState[(int)x])
                    {
                        paused = true;
                        playerPaused = (int)x;
                    }
                }
            }

            if (paused)
            {
                oldState = currState;
                oldStartState[0] = GamePad.GetState(PlayerIndex.One).IsButtonDown(Buttons.Start);
                oldStartState[1] = GamePad.GetState(PlayerIndex.Two).IsButtonDown(Buttons.Start);
                oldStartState[2] = GamePad.GetState(PlayerIndex.Three).IsButtonDown(Buttons.Start);
                oldStartState[3] = GamePad.GetState(PlayerIndex.Four).IsButtonDown(Buttons.Start);

                GamePadState p1 = GamePad.GetState(PlayerIndex.One);
                if (p1.IsButtonDown(Buttons.LeftTrigger) && p1.IsButtonDown(Buttons.RightTrigger) && p1.IsButtonDown(Buttons.LeftShoulder) && p1.IsButtonDown(Buttons.RightShoulder))
                    returnState = levelSelect;
                GamePadState p2 = GamePad.GetState(PlayerIndex.Two);
                if (p2.IsButtonDown(Buttons.LeftTrigger) && p2.IsButtonDown(Buttons.RightTrigger) && p2.IsButtonDown(Buttons.LeftShoulder) && p2.IsButtonDown(Buttons.RightShoulder))
                    returnState = levelSelect;
                GamePadState p3 = GamePad.GetState(PlayerIndex.Three);
                if (p3.IsButtonDown(Buttons.LeftTrigger) && p3.IsButtonDown(Buttons.RightTrigger) && p3.IsButtonDown(Buttons.LeftShoulder) && p3.IsButtonDown(Buttons.RightShoulder))
                    returnState = levelSelect;
                GamePadState p4 = GamePad.GetState(PlayerIndex.Four);
                if (p4.IsButtonDown(Buttons.LeftTrigger) && p4.IsButtonDown(Buttons.RightTrigger) && p4.IsButtonDown(Buttons.LeftShoulder) && p4.IsButtonDown(Buttons.RightShoulder))
                    returnState = levelSelect;
                if (Keyboard.GetState().IsKeyDown(Keys.R))
                    returnState = levelSelect;
                return;
            }

            /* Press TAB to change player if using keyboard. *** For Testing Purposes Only ***
                If you hold down a key while pressing TAB, the previous player will continue to do that same action
                over and over again until you tab to that player again.
                (It is kinda amusing, but could be useful for collison testing) */
            if (currState.IsKeyDown(Keys.Tab) && oldState != currState)
            {
                switch ((int)currPlayer)
                {
                    case 0:
                        currPlayer = PlayerKeys.Player2;
                        break;

                    case 1:
                        currPlayer = PlayerKeys.Player3;
                        break;

                    case 2:
                        currPlayer = PlayerKeys.Player4;
                        break;

                    case 3:
                        currPlayer = PlayerKeys.allPlayers;
                        break;

                    case 4:
                        currPlayer = PlayerKeys.Player1;
                        break;
                }
                //Switches to the next player
            }
            if (currPlayer == PlayerKeys.Player1)
            {
                player1State = Keyboard.GetState();
            }

            if (currPlayer == PlayerKeys.Player2)
            {
                player2State = Keyboard.GetState();
            }

            if (currPlayer == PlayerKeys.Player3)
            {
                player3State = Keyboard.GetState();
            }
            if (currPlayer == PlayerKeys.Player4)
            {
                player4State = Keyboard.GetState();
            }

            if (currPlayer == PlayerKeys.allPlayers)
            {
                player1State = Keyboard.GetState();
                player2State = Keyboard.GetState();
                player3State = Keyboard.GetState();
                player4State = Keyboard.GetState();
            }
            //End of TAB code. Can now only control one player at a time using keyboard.
            player1.Update(player1State, GamePad.GetState(PlayerIndex.One), gameTime);
            player2.Update(player2State, GamePad.GetState(PlayerIndex.Two), gameTime);
            player3.Update(player3State, GamePad.GetState(PlayerIndex.Three), gameTime);
            player4.Update(player4State, GamePad.GetState(PlayerIndex.Four), gameTime);
            foreach (SpearClass sp in spears)
            {

                    if (sp.spearOwner == player1)
                    {
                        sp.Update(player1State, GamePad.GetState(PlayerIndex.One));
                    }

                    else if (sp.spearOwner == player2)
                    {
                        sp.Update(player2State, GamePad.GetState(PlayerIndex.Two));
                    }
                    else if (sp.spearOwner == player3)
                    {
                        sp.Update(player3State, GamePad.GetState(PlayerIndex.Three));
                    }
                    else if (sp.spearOwner == player4)
                    {
                        sp.Update(player4State, GamePad.GetState(PlayerIndex.Four));
                    }
                    else
                    {
                        KeyboardState fakestate = new KeyboardState();
                        GamePadState faker = new GamePadState();
                        sp.Update(fakestate, faker);
                    }
            }
            oldState = currState;

            oldStartState[0] = GamePad.GetState(PlayerIndex.One).IsButtonDown(Buttons.Start);
            oldStartState[1] = GamePad.GetState(PlayerIndex.Two).IsButtonDown(Buttons.Start);
            oldStartState[2] = GamePad.GetState(PlayerIndex.Three).IsButtonDown(Buttons.Start);
            oldStartState[3] = GamePad.GetState(PlayerIndex.Four).IsButtonDown(Buttons.Start);
            //If a timer is running, decrement here

            timeElapsed = (float)gameTime.ElapsedGameTime.TotalSeconds;
            if(roundReset > 0)
            {
                roundReset -= timeElapsed;
                if(roundReset < 0)
                {
                    if (ultimateWin > 0)
                    {
                        returnState = Win;
                        return;
                    }
                    else
                    {
                    resetMap();
                }
            }
            }

            //Update animations
            for (int i = 0; i < animations.Count; i++)
            {
                animations[i].Update(gameTime);
            }
        }
Example #32
0
        public void Initialize()
        {
            player1 = new PlayerClass();
            player2 = new PlayerClass();
            player3 = new PlayerClass();
            player4 = new PlayerClass();

            returnState = null;

            animations = new List<Animation>();

            player1.title = "P1";
            player2.title = "P2";
            player3.title = "P3";
            player4.title = "P4";

            player1.onPlayerKilled += new PlayerClass.PlayerKilledHandler(playerKilled);
            player2.onPlayerKilled += new PlayerClass.PlayerKilledHandler(playerKilled);
            player3.onPlayerKilled += new PlayerClass.PlayerKilledHandler(playerKilled);
            player4.onPlayerKilled += new PlayerClass.PlayerKilledHandler(playerKilled);

            currPlayer = PlayerKeys.Player1;
            paused = false;
            playerPaused = 0;
            AudioManager.TriggerBattle();
        }
Example #33
0
        private void CastPet()
        {
            petID = -1;

            AddMessage("Summoning servant");

            if (_ak.isPlayerSitting)
            {
                PlayerKeys.SitStand(KeyDirection.KeyUpDown);
                Thread.Sleep(1000);
            }

            //test if we are already a shade by checking local buffs
            bool bShade = false;

            AKServer.DLL.DAoCServer.LocalBuffList buffs = _ak.LocalBufs;
            ICollection MyValues = buffs.BuffTable.Values;

            foreach (AKServer.DLL.DAoCServer.LocalBuff buff in MyValues)
            {
                if (buff.Name.StartsWith("Shade"))
                {
                    bShade = true;
                }
            }

            //If we are a shade, we need to change pet stance to get a pet packet from server
            if (bShade)
            {
                //it appears if you log out while the pet is summoned AKServer thinks you still have the Shade buff when you log in again
                //so we try and cast just in case.
                UseQbar(profile.GetString("Necro.SummonPetQ"), profile.GetString("Necro.SummonPetKey"));

                AddMessage("We are already a shade! Trying to get pet ID...");
                UseQbar(profile.GetString("Necro.PetPassiveQ"), profile.GetString("Necro.PetPassiveKey"));
                Thread.Sleep(100);
                UseQbar(profile.GetString("Necro.PetDefensiveQ"), profile.GetString("Necro.PetDefensiveKey"));
                Thread.Sleep(100);
            }
            else
            {
                //switch quickbar and cast
                UseQbar(profile.GetString("Necro.SummonPetQ"), profile.GetString("Necro.SummonPetKey"));
            }

            //No idea why, but I get the localBuff "Shade" sometimes even after a reboot and before casting pet
            //So lets do both and see if we get the packet
//			UseQbar(profile.GetString("PetPassiveQ"),profile.GetString("PetPassiveKey"));
//			Thread.Sleep(100);
//			UseQbar(profile.GetString("PetDefensiveQ"),profile.GetString("PetDefensiveKey"));
//			Thread.Sleep(100);
//			UseQbar(profile.GetString("SummonPetQ"), profile.GetString("SummonPetKey"));


            //Now we can wait for a pet packet to which will fill in petID
            //check once a second for up to 30 seconds
            int sanity = 0;              //no endless loops please

            while (petID <= 0 && sanity++ < 30)
            {
                Thread.Sleep(1000);
            }

            // Did we get the petID?
            if (petID <= 0)
            {
                AddMessage("We didnt find the pet ID!  Restart everything");
                bPaused = true;
            }
            else
            {
                AddMessage("Got Pet ID " + petID.ToString() + " for pet " + _ak.get_MobName(petID));
            }
        }
 void Start()
 {
     player          = PlayerCharacterNew.Instance;
     playerCharMotor = GetComponent <CharacterMotor>();
     keys            = player.keys;
 }
Example #35
0
 virtual public bool getKeyDown(PlayerKeys key)
 {
     return(Input.GetKeyDown(listKeys[(int)key]));
 }