コード例 #1
0
ファイル: StatusBar.cs プロジェクト: superhamis/hamismash
 // Use this for initialization
 void Start()
 {
     RectTransform background = GetComponent<RectTransform> ();
     backgroundWidth = background.sizeDelta.x;
     playerState = PlayerState.Instance;
     playerState.Health = 100;
 }
コード例 #2
0
    public override void ResetGenerationData()
    {
        base.ResetGenerationData();

        currentState = PlayerState.RESPAWNING;
        currentCheckpoint = -1;
    }
コード例 #3
0
ファイル: Zombie.cs プロジェクト: Jemeyr/Halloween
 public Zombie(Vector2 pos)
 {
     this.pos = pos;
     this.playerState = PlayerState.Jump;
     this.order = Order.Follow;
     animationPlayer.PlayAnimation(G.animations["zombie"]);
 }
コード例 #4
0
    PlayerState Move(PlayerState previous, KeyCode newKey)
    {
        float deltaX = 0, deltaY = 0, deltaZ = 0;
        float deltaRotationY = 0;

        switch (newKey) {
            case KeyCode.Q:
                deltaX = -0.5f;
                break;
            case KeyCode.S:
                deltaZ = -0.5f;
                break;
            case KeyCode.E:
                deltaX = 0.5f;
                break;
            case KeyCode.W:
                deltaZ = 0.5f;
                break;
            case KeyCode.A:
                deltaRotationY = -1f;
                break;
            case KeyCode.D:
                deltaRotationY = 1f;
                break;
        }

        return new PlayerState {
            posX = deltaX + previous.posX,
            posY = deltaY + previous.posY,
            posZ = deltaZ + previous.posZ,
            rotX = previous.rotX,
            rotY = deltaRotationY + previous.rotY,
            rotZ = previous.rotZ
        };
    }
コード例 #5
0
ファイル: Player.cs プロジェクト: PythagoRascal/DogmaDerby
    protected override void Awake()
    {
        base.Awake();

        State = PlayerState.Normal;
        _audioSource = GetComponent<AudioSource>();
    }
コード例 #6
0
ファイル: PlayerSave.cs プロジェクト: tedmunds/HavokGear
    public void UpdateFromState(PlayerState state)
    {
        // first cache all of the upgrades unlocked levels
        //for(int i = 0; i < unlockedLevels.Length; i++) {
        //    string upgradeName = unlockedLevels[i].name;
        //
        //    int unlockedLevel;
        //    if(state.upgradeUnlockTable.TryGetValue(upgradeName, out unlockedLevel)) {
        //        unlockedLevels[i].level = unlockedLevel;
        //    }
        //}

        string[] keys = state.upgradeUnlockTable.Keys.ToArray();
        unlockedLevels = new UpgradePair[keys.Length];
        for(int i = 0; i < keys.Length; i++) {
            unlockedLevels[i].name = keys[i];

            int level = 0;
            state.upgradeUnlockTable.TryGetValue(keys[i], out level);
            unlockedLevels[i].level = level;
        }

        availablePoints = state.UpgradePoints;

        //then cache the equipped upgrades and their levels
        equippedUpgrades = new UpgradePair[state.equippedUpgrades.Count];

        for(int i = 0; i < state.equippedUpgrades.Count; i++) {
            equippedUpgrades[i].level = state.equippedUpgrades[i].level;
            equippedUpgrades[i].name = state.equippedUpgrades[i].name;
        }
    }
コード例 #7
0
    private void StepForward()
    {
        // TODO: Parse dialogues/action tree using an XML File instead of a long case statement

        // case set A
        switch (pState) {
            case PlayerState.NORMAL:
                pState = PlayerState.INPUT;
                if (!inputPanel.activeSelf) inputPanel.SetActive(true);
                EventSystem.current.SetSelectedGameObject(inputField.gameObject, null);
                break;
            case PlayerState.NARRATIVE:
                StepNarrative();
                break;
            case PlayerState.INPUT:
                pState = PlayerState.NORMAL;
                inputPanel.SetActive(false);
                break;
            case PlayerState.INTERACT:
                break;
            default:
                break;
        }
        // case set A end
        steps++;
    }
コード例 #8
0
    // Update is called once per frame
    void Update()
    {
        colTag = "Air";
        switch (gameState) {
        case GameState.Playing:
            {
            if(playerState == PlayerState.Running)
           	{
                Debug.Log(colTag);
                if (Input.GetKeyDown (KeyCode.Space))
                {
                    playerState = PlayerState.inAir;
                    Jump();
                    anim.SetInteger("State", 1);

                }
            }
            if(playerState == PlayerState.inAir)
            {
                //Debug.Log(this.GetComponent<Rigidbody2D>().velocity.y);
                if(this.GetComponent<Rigidbody2D>().velocity.y == 0f )
                {
                    jumpNumber = 0;
                    playerState = PlayerState.Running;
                    anim.SetInteger("State", 0);
                }
            }
            break;
            }
        default:
            break;

        }
    }
コード例 #9
0
 //Cancel the currently displayed action
 public void CancelAction()
 {
     selectedUnit = null;
     m_tiles.ClearSelectedTiles();
     m_hud.HideUnitInfo();
     e_playerState = PlayerState.Default;
 }
コード例 #10
0
    public void ChangeMode(PlayerState playerState)
    {
        this.playerState = playerState;

        switch(this.playerState)
        {
        case PlayerState.Normal:
            this.parallaxMode = ParallaxMode.Normal;
            Debug.Log("----- Normal Mode -----");
        break;
        // ------------------------------------------------------------------------------
        case PlayerState.BoostMode:
            this.parallaxMode = ParallaxMode.Boost;
            AudioPlayer.Play(AudioPlayer.PLAYER_BOOST);
            gameVel = this.boostInfo.boostVel;
        break;
        // ------------------------------------------------------------------------------
        case PlayerState.LaserMode:
            AudioPlayer.Play(AudioPlayer.PLAYER_LASER);

        break;
        // ------------------------------------------------------------------------------
        case PlayerState.ScaryDogMode:
            AudioPlayer.Play(AudioPlayer.PLAYER_WOOF);

        break;
        // ------------------------------------------------------------------------------
        case PlayerState.DyingMode:
            this.parallaxMode = ParallaxMode.Dying;
        break;

        }
    }
コード例 #11
0
ファイル: respawn1.cs プロジェクト: gold-games/alpha3
    // Update is called once per frame
    void Update()
    {
        deathtimeout -= Time.deltaTime;
        animationtime -= Time.deltaTime;
                switch (state) {
                case PlayerState.ALIVE:

            //Things that you would call every frame while the character is alive
                        if (myHealth.currentHealth <= 0) {
                                state = PlayerState.DYING;
                        }
                        break;
                case PlayerState.DYING:
            //things you need to do to "kill" the character
                        StartCoroutine (TriggerAnimator ("death"));
            animationtime = 4f;

            //animation.Play("MOB1_M1_Stand_Relaxed_Death_B");
            //THIS IS THE THING THAT HELPS YOU
            //THE PLAYER IS NOW ONLY DYING FOR ONE FRAME AND The ANIMATION PLAY IS ONLY CALLED ONCE
                        state = PlayerState.DEAD;
                        break;
                case PlayerState.DEAD:

            //Anything you need to do to clean up the character such as removing them from the scene or respawning, etc.
            if(deathtimeout <= 0 && animationtime <= 0){
                transform.position = GameObject.FindGameObjectWithTag ("Respawn").transform.position;
                        myHealth.currentHealth = 100;
                deathtimeout = 4.0f;
                state = PlayerState.ALIVE;
            }
                        break;
                }
    }
コード例 #12
0
ファイル: Player.cs プロジェクト: GITHZZ/UnitySprite
 void KeyDownEvent()
 {
     if(Input.GetKeyDown(KeyCode.UpArrow)){
         if(_state == PlayerState.standing) _state = PlayerState.running;
         newIndex = 1;
         if(newIndex != currentIndex) currentIndex = newIndex;
         currentDir = Vector2.up;
     }
     if(Input.GetKeyDown(KeyCode.DownArrow)){
         if(_state == PlayerState.standing) _state = PlayerState.running;
         newIndex = 3;
         if(newIndex != currentIndex) currentIndex = newIndex;
         currentDir = -Vector2.up;
     }
     if(Input.GetKeyDown(KeyCode.LeftArrow)){
         if(_state == PlayerState.standing) _state = PlayerState.running;
         newIndex = 2;
         if(newIndex != currentIndex) currentIndex = newIndex;
         currentDir = -Vector2.right;
     }
     if(Input.GetKeyDown(KeyCode.RightArrow)){
         if(_state == PlayerState.standing) _state = PlayerState.running;
         newIndex = 0;
         if(newIndex != currentIndex) currentIndex = newIndex;
         currentDir = Vector2.right;
     }
 }
コード例 #13
0
ファイル: Spider.cs プロジェクト: YangJinwoo/FPS
	void Start () 
    {
        player = GameObject.Find("Player");
        playerState = player.GetComponent<PlayerState>();
        ani = GetComponent<Animation>();
        ani.Play("Idle");
	}
コード例 #14
0
ファイル: TestCards.cs プロジェクト: peterhal/Dominulator
 public override void DoSpecializedAction(PlayerState currentPlayer, GameState gameState)
 {
     currentPlayer.actionsToExecuteAtBeginningOfNextTurn.Add( delegate()
     {
         currentPlayer.AddCoins(1);
     });
 }
コード例 #15
0
ファイル: GameManager.cs プロジェクト: wchaney98/Hero-Forever
	void Start ()
    {
        // Assign spawners to spawners array
        spawners[0] = topAirSpawner;
        spawners[1] = midAirSpawner;
        spawners[2] = botAirSpawner;
        spawners[3] = groundSpawner;

        // Initialize texts to their respective GO's
        hudPlayerHealth = HudPlayerHealthObj.GetComponent<Text>();
        hudPlayerGold = HudPlayerGoldObj.GetComponent<Text>();
        hudPlayerXP = HudPlayerXPObj.GetComponent<Text>();

        // Initialize wave-time to 0
        timeSinceWave = 0;

        // Initialize PlayerState struct
        playerState = new PlayerState(startingPlayerHealth, xpMultiplier, startingPlayerGold, startingPlayerXP, firstToSecondLevelXP);

        // Initially disable attribute panel
        GameObject.Find("AttributePanel").SetActive(false);

        // Load attribute panel toggle label text ref
        attrPanelToggLabel = GameObject.Find("Label").GetComponent<Text>();

        // Init ref to Canvas object
        canvas = GameObject.Find("Canvas").GetComponent<Canvas>();
    }
コード例 #16
0
    // Use this for initialization
    void Start()
    {
        _instance = this;
        isShowPanel = false;
        npcManager =NPCManager._instance;
        NPCDictionary = npcManager.GetNPCDctionary();
        playerState = PlayerState._instance;
        mainControllerUI = UIController._instance;

        foreach (KeyValuePair<int, GameObject> item in NPCDictionary)
        {
            item.Value.GetComponent<NPCInfomation>().CommunicationStart += CommunicationTalk;
        }

        #region UI
        containItems = transform.Find("TalkContainer").Find("Scroll View").Find("Items").gameObject;


        talkLabel = containItems.transform.Find("TalkLabel").GetComponent<UILabel>();
        shopButton = containItems.transform.Find("ShopButton").GetComponent<UIButton>();
        questButton = containItems.transform.Find("QuestButton").GetComponent<UIButton>();
        bagManagerUI = GameObject.FindGameObjectWithTag(Tags.UIRoot).transform.Find("EquepMenu").GetComponent<UIBagManager>();
        npcQuestManagerUI = GameObject.FindGameObjectWithTag(Tags.UIRoot).transform.Find("NPCQuestPanel").GetComponent<UINPCQuestManager>();
        #endregion

        gameObject.SetActive(false);
    }
コード例 #17
0
        public override void Update(GameTime gameTime)
        {
            if (!GameState.IsPaused)
            {
                if (GameState.IsEnd)
                {
                    ShowLabels.ShowEndGame();
                    FirstSprite.HandleSpriteMovement(gameTime);
                    SecondSprite.HandleSpriteMovement(gameTime);
                    if (!GameState.IsEnd)
                    {
                        FirstSprite.Stop();
                        SecondSprite.Stop();
                    }
                }
                else
                {
                    ShowLabels.ShowWinner();
                    ShowLabels.ShowRound();
                    firstState = FirstSprite.HandleSpriteMovement(gameTime);
                    secondState = SecondSprite.HandleSpriteMovement(gameTime);

                    if (firstState == PlayerState.Move || secondState == PlayerState.Move)
                        CollideDetector.RepairMoveCollision(FirstSprite, SecondSprite, width);
                    CollideDetector.HitCollision(FirstSprite, SecondSprite, gameTime);
                    FirstHealthBar.Update(FirstSprite.Information.Health);
                    SecondHealthBar.Update(SecondSprite.Information.Health);
                    WinnerDetector.DetectWinner(gameTime, FirstSprite, SecondSprite);
                }
                base.Update(gameTime);
            }
        }
コード例 #18
0
ファイル: GameState.cs プロジェクト: PeteJBB/SupremeViolence
    public static void StartNewGame()
    {
        Debug.Log("GameState StartNewGame");

        CurrentRound = 0;
        Players = new List<PlayerState>();
        for(var i=0; i<GameSettings.NumberOfPlayers; i++)
        {
            var pState = new PlayerState(i);
            switch(i)
            {
                case 0:
                default:
                    pState.Color = new Color(.2f, .4f, 1); // blue
                    break;
                case 1:
                    pState.Color = Color.red;
                    break;
                case 2:
                    pState.Color = Color.green;
                    break;
                case 3:
                    pState.Color = new Color(1,0,1); // purple
                    break;
            }
            Players.Add(pState);
        }

        AudioListener.volume = 1;// GameSettings.SoundVolume / 10f;

        IsGameStarted = true;
    }
コード例 #19
0
ファイル: Player.cs プロジェクト: pxl1778/Armoire
 public Player(Random rand)
 {
     pos = new Vector2(50, 1100);
     velocity = new Vector2(0, 0);
     acceleration = new Vector2(0, 0);
     forward = new Vector2(1, 0);
     pState = PlayerState.idle;
     dState = DirectionState.right;
     width = 23;
     height = 45;
     rect = new Rectangle((int)pos.X, (int)pos.Y, width, height);
     fps = 10.0;
     timePerFrame = 1.0 / fps;
     frame = 0;
     maxForce = 20f;
     maxSpeed = new Vector2(3f, 5f);
     decceleration = .9f;
     canJump = true;
     helmets = new Stack<Helmet>();
     chestplates = new Stack<ChestPlate>();
     gloves = new Stack<Gloves>();
     this.rand = rand;
     chargeCounter = 0.0;
     armorScale = 1.0f;
     armorLevel = 0;
     invincible = false;
     Initialize();
 }
コード例 #20
0
ファイル: APlayer.cs プロジェクト: gleroi/k-rabbit
 public static void Is(Player player, int x, int y, int score, PlayerState state)
 {
     Assert.Equal(x, player.Pos.X);
     Assert.Equal(y, player.Pos.Y);
     Assert.Equal(score, player.Score);
     Assert.Equal(state, player.State);
 }
コード例 #21
0
        public void Input()
        {
            KeyboardState currentKeyBoardState = Keyboard.GetState();

            if (currentKeyBoardState.IsKeyDown(Keys.Space))
            {
                currentPlayerState = PlayerState.Flying;

                if (currentPlayerState == PlayerState.Flying)
                {
                    Flying();
                }

                if (currentPlayerState == PlayerState.Falling)
                {
                    Falling();
                }
            }

            if (currentKeyBoardState.IsKeyUp(Keys.Space))
            {
                loopCount = 0;
                currentPlayerState = PlayerState.Falling;
                Falling();
            }
        }
コード例 #22
0
 // Use this for initialization
 void Awake()
 {
     ItemInfoPanel = GameObject.FindGameObjectWithTag(Tags.UIRoot).transform.Find("EquepMenu").Find("ItemInfoPanel").GetComponent<UIItemInfoPanel>();
     playerState = PlayerState._instance;
     OnEquepChanged();
     playerState.OnPlayerStateChanged += OnStateChanged;
 }
コード例 #23
0
ファイル: SpikeTrigger.cs プロジェクト: Jarbuckle/purgatory
 // Use this for initialization
 void Awake()
 {
     state = 3;
     playerHealth = GameObject.Find("Player").GetComponent<PlayerState>();
     spikes = transform.Find("spiketrap_spikes");
     a = GetComponent<AudioSource>();
 }
コード例 #24
0
ファイル: Player_Ctrl.cs プロジェクト: CodeZob/BoxRunner
    void GameOver()
    {
        ePS = PlayerState.DEATH;
        SoundPlay(ESound.DEATH);

        GM.GameOver();
    }
コード例 #25
0
ファイル: PlayerFSM.cs プロジェクト: JulianG/MossRunningGame
 private void SetState(PlayerState new_state)
 {
     if (this.currentState != null)
         this.currentState.End ();
     this.currentState = new_state;
     this.currentState.Start ();
 }
コード例 #26
0
 void handleInput()
 {
     PlayerState state = playerState_.handleInput ();
     if (state != null) {
         playerState_ = state;
     }
 }
コード例 #27
0
 //    public LevelState level;
 //Stats
 //    public float timePlayed = 0.0F;
 public SafeState()
 {
     //		current = new SafeState();
     //		allLevels = new List<LevelState>();
     //		level = new LevelState();
     player = new PlayerState();
 }
コード例 #28
0
    void FixedUpdate()
    {
        if (Input.GetAxisRaw("Switch Form") != 0 && m_StateTimer == 0)
        {
            m_Human.IsActive = !m_Human.IsActive;
            m_Spirit.IsActive = !m_Spirit.IsActive;

            if (m_Human.IsActive)
            {
                m_PlayerState = PlayerState.HUMAN;
                m_Camera.Following = m_Human.gameObject;
            }
            else
            {
                m_PlayerState = PlayerState.SPIRIT;
                m_Camera.Following = m_Spirit.gameObject;
            }
            m_Human.GetComponent<SpriteRenderer>().enabled = !m_Human.GetComponent<SpriteRenderer>().enabled;
            m_Spirit.GetComponent<SpriteRenderer>().enabled = !m_Spirit.GetComponent<SpriteRenderer>().enabled;

            ChangeSceneMode();

            m_StateTimer = 0.5f;
        }
        else if (m_StateTimer > 0)
        {
            m_StateTimer -= Time.deltaTime;
            m_StateTimer = Mathf.Clamp(m_StateTimer, 0.0f, m_StateTimer);
        }
    }
コード例 #29
0
ファイル: PlayerIso.cs プロジェクト: shotgunfoot/GAME-SCRIPTS
 // Use this for initialization
 protected override void Start()
 {
     base.Start();
     pController = GetComponent<PlayerControllerIso>();
     pState = PlayerState.RUNNING;
     canRoll = true;
 }
コード例 #30
0
ファイル: PlayerBehavior.cs プロジェクト: jaumefc/arkanoid
 public PlayerBehavior()
     : base("PlayerBehavior")
 {
     this.direction = NONE;
     this.trans2D = null;
     this.currentState = PlayerState.Idle;
 }
コード例 #31
0
 public void AnotherFunction <T>(PlayerState <T> state)
コード例 #32
0
    void CheckPushPull()
    {
        //  if player currently already pushing/pull an object then cancel the push/pull interaction
        if (currentState == PlayerState.PushingPulling)
        {
            CancelPushingPulling();
        }
        //  else check for any objects within distance to push/pull
        else
        {
            //  Determine direction to cast ray
            Vector3 dir;
            if (facingDirection == FacingDirection.Right)
            {
                dir = Vector3.right;
            }
            else
            {
                dir = Vector3.left;
            }

            //  cast ray
            RaycastHit hit;
            Physics.Raycast(transform.position, dir, out hit, pushpullDistance, Layers.PushPullable);
            if (Application.isEditor)
            {
                Debug.DrawRay(transform.position, dir * pushpullDistance, Color.red, 5f);
            }

            //  Evaluate hit
            if (hit.collider)
            {
                //Debug.Log("Holding objecT: " + hit.collider.name);
                //  Update player state
                currentState = PlayerState.PushingPulling;

                //  Reset x velocity
                velocity.x = 0;

                //  Cache pushing/pulling body
                pushpullObject = hit.transform.GetComponent <PushPullObject>();
                //pushPullRigidBody = hit.transform.GetComponent<Rigidbody>();
                pushpullObject.transform.SetParent(transform);

                //  Set the pushing/pulling break distance
                pushpullBreakDistance = Vector3.Distance(pushpullObject.transform.position, transform.position);

                //  Process interaction event to the push/pull object
                pushpullObject.OnPushPullStart();

                //  Animation
                animator.SetBool(isPushPullingHash, true);

                //  Events
                if (OnPushPullStart != null)
                {
                    OnPushPullStart(pushpullObject);
                }
            }
        }
    }
コード例 #33
0
 private void OnBackToMenu()
 {
     GameManager.TimeScale = 1f;
     currentState          = PlayerState.Idle;
     transform.position    = Vector3.zero;
 }
コード例 #34
0
 private void OnGameOver()
 {
     currentState     = PlayerState.GameOver;
     Cursor.visible   = true;
     Cursor.lockState = CursorLockMode.None;
 }
コード例 #35
0
ファイル: Player.cs プロジェクト: luizlls/dotz
 void Awake()
 {
     state = PlayerState.Alive;
     body  = GetComponent <Rigidbody2D>();
 }
コード例 #36
0
ファイル: Chess.cs プロジェクト: 70rustsk/repos
 private void showPromote()
 {
     playerState   = PlayerState.AwaitPromote;
     promoteOption = PromoteOptions.Queen;
 }
コード例 #37
0
ファイル: Chess.cs プロジェクト: 70rustsk/repos
 private void cancel()//если esc
 {
     playerState = PlayerState.Idle;
     holdedNode  = null;
 }
コード例 #38
0
ファイル: PlayerPrototype.cs プロジェクト: IAmEska/Jumpy
 public void SetState(PlayerState state)
 {
     this.state = state;
 }
コード例 #39
0
 public void SetState(PlayerState newState)
 {
     state = newState;
 }
コード例 #40
0
ファイル: PlayerPrototype.cs プロジェクト: IAmEska/Jumpy
 public void Kill()
 {
     state = PlayerState.Dead;
     _collider.isTrigger = true;
 }
コード例 #41
0
 void OnGround()
 {
     ZeroVelocity();
     currentPlayerState = PlayerState.onground;
 }
コード例 #42
0
ファイル: PlayerPrototype.cs プロジェクト: IAmEska/Jumpy
    void FixedUpdate()
    {
        if (_prevSelectedBehaviour != selectedBehaviour || _behaviour == null)
        {
            if (_behaviour != null)
            {
                Destroy(_behaviour);
            }

            System.Type type;
            switch (selectedBehaviour)
            {
            default:
                type = typeof(JumpingPlayerBehaviour);
                break;
            }

            _behaviour = gameObject.AddComponent(type) as AbstractPlayerBehaviour;
        }

        if (_doDoubleJump)
        {
            _doDoubleJump           = false;
            _behaviour.doDoubleJump = true;
        }

        switch (state)
        {
        case PlayerState.Idle:
            //Do Nothing
            break;

        case PlayerState.Dead:
            if (_prevState != state)
            {
                transform.Rotate(Vector3.forward, 180);
            }
            break;

        case PlayerState.Grounded:
            if (isImmortal)
            {
                isImmortal = false;
            }

            // StopCoroutine(JumpAnimation());
            //StartCoroutine(JumpAnimation());
            _groundedWait = false;

            _canDoubleJump = true;
            _behaviour.GroundedBehaviour();
            break;

        case PlayerState.InAir:

            if (_prevState != state)
            {
                _animator.SetFloat(ANIM_FORCE, 0.5f);
            }


            if (mRigidbody.velocity.y <= 0)
            {
                state = PlayerState.Falling;
            }

            _behaviour.InAirBehaviour();

            if (!_animationSet && mRigidbody.velocity.y <= 0.5f)
            {
                _animationSet = true;
                _animator.SetFloat(ANIM_FORCE, 1);
            }

            break;

        case PlayerState.Falling:
            _animationSet = false;
            _behaviour.FallingBehaivour();
            if (!_groundedWait && CheckGroundCollision())
            {
                _groundedWait = true;
                _animator.SetFloat(ANIM_FORCE, 0);
                StopCoroutine(GroundedWait());
                StartCoroutine(GroundedWait());
            }
            break;
        }

        if (transform.position.x < _areaMinX)
        {
            transform.position = new Vector3(_areaMaxX, transform.position.y);
        }

        if (transform.position.x > _areaMaxX)
        {
            transform.position = new Vector3(_areaMinX, transform.position.y);
        }

        _prevState             = state;
        _prevSelectedBehaviour = selectedBehaviour;

        if (direction != _prevDirection)
        {
            Vector3 newScale = transform.localScale;
            newScale.x           = _defaultScaleX * direction;
            transform.localScale = newScale;
        }

        _prevDirection = direction;
    }
コード例 #43
0
 public Player(string playerID, PlayerState state)
 {
     PlayerID     = playerID;
     CurrentState = state;
 }
コード例 #44
0
 // Use this for initialization
 void Start()
 {
     currentPlayerState = PlayerState.falling;
     rb = gameObject.GetComponent <Rigidbody2D>();
     ResetClamp();
 }
コード例 #45
0
        public override void Update(GameTime gameTime)
        {
            timeSinceBombPlant += gameTime.ElapsedGameTime.TotalSeconds;
            if (timeSinceBombPlant >= BOMB_INTERVAL)
            {
                bombActive         = false;
                timeSinceBombPlant = 0;
            }

            KeyboardState ks = Keyboard.GetState();

            //if (!bombActive)

            /*if (currnetlyUsingBomb < numberOfBomb)
             * {
             *  if (ks.IsKeyDown(Keys.Space))
             *  {
             *      //if()
             *      //plant a bomb on the hero's currnet position
             *      bombPosition = position;
             *      currnetlyUsingBomb++;
             *      bombActive = true;
             *      //bomb.
             *  }
             * }*/

            if (this.Visible)
            {
                if (ks.IsKeyDown(Keys.Up))
                {
                    playerState = PlayerState.Jump;
                    position.Y -= speed;
                }
                else if (ks.IsKeyDown(Keys.Down))
                {
                    playerState = PlayerState.Duck;
                    position.Y += speed;
                }
                else if (ks.IsKeyDown(Keys.Right))
                {
                    playerState = PlayerState.WalkingRight;
                    position.X += speed;
                }
                else if (ks.IsKeyDown(Keys.Left))
                {
                    playerState = PlayerState.WalkingLeft;
                    position.X -= speed;
                }
                else
                {
                    playerState = PlayerState.Idle;
                }
            }
            position.X = MathHelper.Clamp(position.X, 0, GraphicsDevice.Viewport.Width - textureIdle.Width);
            int playerHeight = playerState == PlayerState.Duck ? textureDuck[0].Height : textureIdle.Height;

            position.Y = MathHelper.Clamp(position.Y, 0, GraphicsDevice.Viewport.Height - playerHeight);


            // update our frame info
            timeSinceLastFrame += gameTime.ElapsedGameTime.TotalSeconds;
            if (timeSinceLastFrame > FRAME_RATE)
            {
                switch (playerState)
                {
                case PlayerState.Idle:
                    currentFrame       = 0;
                    timeSinceLastFrame = 0;
                    break;

                case PlayerState.WalkingLeft:
                case PlayerState.WalkingRight:
                    if (++currentFrame >= WALK_FRAME_COUNT)
                    {
                        currentFrame       = 0;
                        timeSinceLastFrame = 0;
                    }
                    break;

                case PlayerState.Duck:
                    if (++currentFrame >= JUMPDUCK_FRAME_COUNT)
                    {
                        currentFrame       = 0;
                        timeSinceLastFrame = 0;
                    }
                    break;

                case PlayerState.Jump:
                    if (++currentFrame >= JUMPDUCK_FRAME_COUNT)
                    {
                        currentFrame       = 0;
                        timeSinceLastFrame = 0;
                    }
                    break;
                }
            }

            // here we make sure that we are not off screen, we
            // clap the value to between 0 and width of screen - texture width
            base.Update(gameTime);
        }
コード例 #46
0
 public Player SetState(PlayerState state) => new Player(PlayerID, state);
コード例 #47
0
 public void ForceEnterState(PlayerState newState)
 {
     CheckNewState(newState);
 }
コード例 #48
0
 public GameStateUtility()
 {
     playerState = new PlayerState();
 }
コード例 #49
0
ファイル: ConnectedPlayer.cs プロジェクト: Orom/HyperSphere
 public void SetPlayerState(PlayerState newPlayerState)
 {
     currentPlayerState = newPlayerState;
 }
コード例 #50
0
    void Update()
    {
        agent.SetDestination(moveTarget.transform.position);
        if (playerState != PlayerState.idle)
        {
            if (playerState == PlayerState.combat)
            {
                Vector3 relativePos = moveTarget.transform.position - playerMesh.transform.position;
                relativePos.y = 0;
                Quaternion rotation = Quaternion.LookRotation(relativePos);
                playerMesh.rotation = rotation;
            }
            else
            {
                Vector3 moveTargetTempPos = new Vector3(moveTarget.transform.position.x + extension.x, moveTarget.transform.position.y, moveTarget.transform.position.z + extension.z);
                Vector3 relativePos       = moveTargetTempPos - playerMesh.transform.position;
                relativePos.y = 0;
                Quaternion rotation = Quaternion.LookRotation(relativePos);
                playerMesh.rotation = rotation;
            }
        }

        if (Input.GetMouseButtonDown(1))
        {
            Ray        ray = Camera.main.ScreenPointToRay(Input.mousePosition);
            RaycastHit hit;

            if (Physics.Raycast(ray, out hit, 100, ignoreWhenNavigating))
            {
                Debug.DrawLine(ray.origin, hit.point, Color.red, 2);
                lastidleTime = Time.time;

                if (hit.transform.tag == "Pickup")
                {
                    playerState = PlayerState.pickup;
                    itemTarget  = hit.transform.gameObject;
                }
                else if (hit.transform.tag == "Combat")
                {
                    playerState = PlayerState.combat;
                    enemyTarget = hit.transform.parent.gameObject;
                }
                else
                {
                    playerState = PlayerState.walk;
                }

                HandleAnimation();
                startMarker = transform.position;
                endMarker   = hit.point;
                endMarker.y = startMarker.y;

                moveTarget.transform.position = endMarker;
                extension = (moveTarget.transform.position - playerMesh.transform.position).normalized * 5;
                //UpdateTargetDir();
            }
        }
        if (playerState == PlayerState.pickup && Vector3.Distance(transform.position, itemTarget.transform.position) < itemRange)
        {
            Destroy(itemTarget);
            itemTarget  = null;
            playerState = PlayerState.walk;
            //ConvertToUI();
        }
        else if (playerState == PlayerState.combat || playerState == PlayerState.inCombat)
        {
            if (enemyTarget)
            {
                if (enemyTarget.GetComponent <EnemyAttack>().currentHealth > 0)
                {
                    if (Attack())
                    {
                        playerState = PlayerState.inCombat;
                        //HandleAnimation();
                    }
                }
                else
                {
                    playerState = PlayerState.walk;
                }
            }
            else
            {
                playerState = PlayerState.walk;
            }
        }
        else if (playerState == PlayerState.walk)
        {
            if (agent.velocity.magnitude <= 0.1f)
            {
                if (Time.time - lastidleTime > idleTimeMin)
                {
                    playerState = PlayerState.idle;

                    //HandleAnimation();
                    lastidleTime = Time.time;
                }
            }
        }
        //print(playerState);
        if (!agent.pathPending)
        {
            if (agent.remainingDistance <= agent.stoppingDistance)
            {
                if (!agent.hasPath || agent.velocity.sqrMagnitude == 0f)
                {
                    //playerState = PlayerState.idle;
                }
            }
        }

        HandleAnimation();
    }
コード例 #51
0
 public void PreBlock()
 {
     playerState = PlayerState.block;
 }
コード例 #52
0
ファイル: ConnectedPlayer.cs プロジェクト: Orom/HyperSphere
 public ConnectedPlayer(string name)
 {
     this.name          = name;
     currentPlayerState = PlayerState.OBSERVER;
 }
コード例 #53
0
        private void Start()
        {
            lastPlayerState = playerState;

            GetStateBehaviour(playerState)?.OnStateEnter(this);
        }
コード例 #54
0
 public PlayerStateChangedEventArgs(PlayerState state)
 {
     State = state;
 }
コード例 #55
0
ファイル: Player.cs プロジェクト: llssyy404/ProjectRPG
 public void OnAttackSkill()
 {
     isOnSkill = true;
     PS        = PlayerState.ATTACK1;
 }
コード例 #56
0
    private void Update()
    {
        if (isServer)
        {
            if (rigidBo.velocity.x > 0.00001f || rigidBo.velocity.x < -0.00001f)
            {
                flipstate = rigidBo.velocity.x > 0.00001f;
            }
        }


        spriteRenderer.flipX = flipstate;

        if (playerState != PlayerState.dead && health <= 0)
        {
            playerState = PlayerState.dead;
            animator.SetInteger("PlayerState", (int)playerState);
            rigidBo.isKinematic  = true;
            cinemachineVC.Follow = null;
            cinemachineVC.LookAt = null;
        }
        if (playerState == PlayerState.dead || !isLocalPlayer)
        {
            return;
        }

        Vector3 lookatOffset   = new Vector3();
        float   speedThreshold = 0.2f;
        float   offset         = 0.8f;

        if (rigidBo.velocity.x > speedThreshold)
        {
            lookatOffset.x = offset * transform.lossyScale.x;
        }
        else if (rigidBo.velocity.x < -speedThreshold)
        {
            lookatOffset.x = -offset * transform.lossyScale.x;
        }
        if (rigidBo.velocity.y > speedThreshold)
        {
            lookatOffset.y = offset * 0.4f * transform.lossyScale.y;
        }
        else if (rigidBo.velocity.y < -speedThreshold)
        {
            lookatOffset.y = -offset * 0.4f * transform.lossyScale.y;
        }
        lookAtPoint.transform.position = transform.position + lookatOffset;

        sinceKickTime  += Time.deltaTime;
        sincePunchTime += Time.deltaTime;
        sinceJump      += Time.deltaTime;

        if (playerState == PlayerState.jumping && rigidBo.velocity.y > 0.0f)
        {
            playerState = PlayerState.jumping;
        }

        else if ((playerState == PlayerState.jumping || playerState == PlayerState.idle) && rigidBo.velocity.y < 0.0f)
        {
            playerState = PlayerState.falling;
        }

        else if (playerState == PlayerState.falling && rigidBo.velocity.y <= 0.01f && rigidBo.velocity.y >= -0.01f)
        {
            playerState = PlayerState.idle;
        }

        else if (playerState == PlayerState.walking && rigidBo.velocity.x <= 0.01f && rigidBo.velocity.x >= -0.01f)
        {
            playerState = PlayerState.idle;
        }

        else if (playerState == PlayerState.punch && sincePunchTime > punchSpeed)
        {
            playerState = PlayerState.idle;
        }

        else if (playerState == PlayerState.kick && sinceKickTime > punchSpeed)
        {
            playerState = PlayerState.idle;
        }

        animator.SetInteger("PlayerState", (int)playerState);
    }
コード例 #57
0
        public void SetMediaItem(IResourceLocator locator, string mediaItemTitle, MediaItem mediaItem)
        {
            _mediaItem = mediaItem;

            // free previous opened resource
            FilterGraphTools.TryDispose(ref _resourceAccessor);
            FilterGraphTools.TryDispose(ref _rot);

            _state    = PlayerState.Active;
            _isPaused = true;
            try
            {
                _resourceLocator = locator;
                _mediaItemTitle  = mediaItemTitle;
                CreateResourceAccessor();

                // Create a DirectShow FilterGraph
                CreateGraphBuilder();

                // Add it in ROT (Running Object Table) for debug purpose, it allows to view the Graph from outside (i.e. graphedit)
                _rot = new DsROTEntry(_graphBuilder);

                // Add a notification handler (see WndProc)
                _instancePtr = IntPtr.Zero;
                if (_me != null)
                {
                    _me.SetNotifyWindow(SkinContext.Form.Handle, WM_GRAPHNOTIFY, _instancePtr);
                }

                // Create the Allocator / Presenter object
                AddPresenter();

                ServiceRegistration.Get <ILogger>().Debug("{0}: Adding audio renderer", PlayerTitle);
                AddAudioRenderer();

                ServiceRegistration.Get <ILogger>().Debug("{0}: Adding preferred codecs", PlayerTitle);
                AddPreferredCodecs();

                ServiceRegistration.Get <ILogger>().Debug("{0}: Adding source filter", PlayerTitle);
                AddSourceFilter();

                ServiceRegistration.Get <ILogger>().Debug("{0}: Set subtitle renderer", PlayerTitle);
                SetSubtitleRenderer();
                ServiceRegistration.Get <ILogger>().Debug("{0}: Adding subtitle filter", PlayerTitle);
                AddSubtitleFilter(true);

                ServiceRegistration.Get <ILogger>().Debug("{0}: Run graph", PlayerTitle);

                //This needs to be done here before we check if the evr pins are connected
                //since this method gives players the chance to render the last bits of the graph
                OnBeforeGraphRunning();

                // Now run the graph, i.e. the DVD player needs a running graph before getting informations from dvd filter.
                int hr = _mc.Run();
                new HRESULT(hr).Throw();

                _initialized = true;
                OnGraphRunning();
            }
            catch (Exception)
            {
                Shutdown();
                throw;
            }
        }
コード例 #58
0
        protected override void OnTarget(Mobile from, object targeted)
        {
            if (GuildGump.BadMember(this.m_Mobile, this.m_Guild))
            {
                return;
            }

            if (targeted is Mobile)
            {
                Mobile m = (Mobile)targeted;

                PlayerState guildState  = PlayerState.Find(this.m_Guild.Leader);
                PlayerState targetState = PlayerState.Find(m);

                Faction guildFaction  = (guildState == null ? null : guildState.Faction);
                Faction targetFaction = (targetState == null ? null : targetState.Faction);

                if (!m.Player)
                {
                    this.m_Mobile.SendLocalizedMessage(501161); // You may only recruit players into the guild.
                }
                else if (!m.Alive)
                {
                    this.m_Mobile.SendLocalizedMessage(501162); // Only the living may be recruited.
                }
                else if (this.m_Guild.IsMember(m))
                {
                    this.m_Mobile.SendLocalizedMessage(501163); // They are already a guildmember!
                }
                else if (this.m_Guild.Candidates.Contains(m))
                {
                    this.m_Mobile.SendLocalizedMessage(501164); // They are already a candidate.
                }
                else if (this.m_Guild.Accepted.Contains(m))
                {
                    this.m_Mobile.SendLocalizedMessage(501165); // They have already been accepted for membership, and merely need to use the Guildstone to gain full membership.
                }
                else if (m.Guild != null)
                {
                    this.m_Mobile.SendLocalizedMessage(501166); // You can only recruit candidates who are not already in a guild.
                }
                #region Factions
                else if (guildFaction != targetFaction)
                {
                    if (guildFaction == null)
                    {
                        this.m_Mobile.SendLocalizedMessage(1013027); // That player cannot join a non-faction guild.
                    }
                    else if (targetFaction == null)
                    {
                        this.m_Mobile.SendLocalizedMessage(1013026); // That player must be in a faction before joining this guild.
                    }
                    else
                    {
                        this.m_Mobile.SendLocalizedMessage(1013028); // That person has a different faction affiliation.
                    }
                }
                else if (targetState != null && targetState.IsLeaving)
                {
                    // OSI does this quite strangely, so we'll just do it this way
                    this.m_Mobile.SendMessage("That person is quitting their faction and so you may not recruit them.");
                }
                #endregion
                else if (this.m_Mobile.AccessLevel >= AccessLevel.GameMaster || this.m_Guild.Leader == this.m_Mobile)
                {
                    this.m_Guild.Accepted.Add(m);
                }
                else
                {
                    this.m_Guild.Candidates.Add(m);
                }
            }
        }
コード例 #59
0
 public void Push()
 {
     state = PlayerState.Push;
     animator.SetTrigger("Push");
 }
コード例 #60
0
ファイル: Player.cs プロジェクト: llssyy404/ProjectRPG
 public void OnIdel()
 {
     PS      = PlayerState.IDEL;
     _isMove = false;
 }