예제 #1
0
    // Use this for initialization
    void Awake()
    {
        playerColl = GetComponent <Collider2D>();

        playerAnim = GetComponent <PlayerAnim>();
        rb         = GetComponent <Rigidbody2D>();
    }
예제 #2
0
 void Start()
 {
     baseSpeed  = speed;
     playerAnim = GetComponent <PlayerAnim>();
     rigidbody  = GetComponent <Rigidbody>();
     StartCoroutine(Move());
 }
예제 #3
0
    public override void Interact()
    {
        ProgressStatus status     = PlayerScan.instance.progressStatus;
        PlayerAnim     skinstatus = AnimationManager.instance.playerAnim;

        if ((status == ProgressStatus.E_Start || status == ProgressStatus.E_JungGotShocked) && skinstatus == PlayerAnim.E_Uniform)
        {
            SoundManager.PlaySFX("clothes");
            AnimationManager.instance.ChangePlayerAnim(PlayerAnim.E_Pajama);
            if (status == ProgressStatus.E_Start)
            {
                PlayerScan.instance.progressStatus = ProgressStatus.E_ChangeClothes;
            }
            else if (status == ProgressStatus.E_JungGotShocked)
            {
                PlayerScan.instance.progressStatus = ProgressStatus.E_ChangeClothes2;
            }
            AnimationManager.instance.playerAnim = PlayerAnim.E_Pajama;
        }
        else if (GameManager.CheckCondition(ProgressStatus.E_Chapter2Start, PlayerAnim.E_Pajama))
        {
            SoundManager.PlaySFX("clothes");                                        //기획서에 없지만 일단 추가
            AnimationManager.instance.ChangePlayerAnim(PlayerAnim.E_Uniform);
            AnimationManager.instance.playerAnim = PlayerAnim.E_Uniform;
            ObjectManager.GetObject <LivingRoomDoor>().isOpened    = true;
            ObjectManager.GetObject <FrontDoor>().isOpened         = true;
            ObjectManager.GetObject <ToSuperMarketDoor>().isOpened = false;
            ObjectManager.GetObject <ToSchoolDoor>().isOpened      = true;
        }
    }
예제 #4
0
    //  MainMethod - AttackAnim
    private void AttackAnim()
    {
        if (animCool < 0)
        {
            animCool = 0.25f;

            if (animCount < 1)
            {
                animCount++;
            }

            else
            {
                animCount = 0;
                pAnim     = PlayerAnim.MOVE;
            }
        }

        else
        {
            animCool -= Time.deltaTime;
        }

        sr.sprite = animMoveList[animCount];
    }
예제 #5
0
    // Start is called before the first frame update
    void Start()
    {
        movementSpeed = new float[] { 4.75f, 5.50f, 6.00f, 6.5f, 7.0f };

        deltaTime      = 0.0f;
        movementLevel  = 0;
        timeLeft       = 0.2f;
        numberOfDashes = 3;

        health = 3;

        isDashing  = false;
        raycastHit = false;
        attacking  = false;

        previousPositions = new Queue <Vector2>();

        rigidBody      = transform.GetComponent <Rigidbody2D>();
        playerCollider = transform.GetComponent <BoxCollider2D>();
        anim           = transform.GetComponentInChildren <PlayerAnim>();

        sceneController = GameObject.Find("SceneController");

        Physics2D.gravity = new Vector2(0, -40.0f);
    }
예제 #6
0
    public Player(int id, PlayerData playerData)
    {
        if (playerData == null)
        {
            return;
        }
        m_playerData = playerData;
        m_id         = id;

        GameResModuel resModuel = GameStart.GetInstance().ResModuel;
        GameObject    player    = resModuel.LoadResources <GameObject>(EResourceType.Role, playerData.m_playerResPath);

        player = CommonFunc.Instantiate(player);
        if (player != null)
        {
            player.name = playerData.m_playerName;
            m_avatar    = player.AddComponent <PlayerAvatar>();

            m_anim = new PlayerAnim(player);
            m_anim.InitAnimator(playerData.m_animControllerName);

            GameObject collider = CommonFunc.GetChild(player, "Collider");
            m_collider = new PlayerCollider(playerData.m_moveArea, playerData.m_radius, playerData.m_angle, collider.GetComponent <BoxCollider2D>());

            MovePosition(m_playerData.m_bornPosition);
        }
    }
예제 #7
0
    void OnCollisionEnter(Collision other)
    {
        explosionSound.Play();

        if (other.gameObject.tag == "Player2" || other.gameObject.tag == "Player1")
        {
            PlayerAnim panim = other.gameObject.GetComponent <PlayerAnim>();
            PlayerData pData = other.gameObject.GetComponent <PlayerData>();

            Debug.Log("Collided with: " + other.gameObject.name);
            //Debug.Log("Player Attack 1: " + pAttack.getAttack1);

            if (!gameObject.GetComponent <SpellFire>().getStrongAttack)
            {
                healthManager.takeDamage(other.gameObject, pData.lightAttackDamage);
                panim.lightHit();
            }
            else
            {
                healthManager.takeDamage(other.gameObject, pData.heavyAttackDamage);
                panim.lightHit();
            }

            Destroy(gameObject);
        }
        else
        {
            Destroy(gameObject);
        }
    }
예제 #8
0
    public void FaintCheck()
    {
        faint = true;
        PlayerAnim pAnim = pig.GetComponent <PlayerAnim>();

        pAnim.FiantAnimOn();
    }
    protected override void Update()
    {
        if (!canBeControlled)
        {
            return;
        }
        float vitesse = _Movement_Update();

        _Camera_Update();
        _Controls_Update();
        _PickItem_Update();

        if (vitesse > 0)
        {
            PlayerAnim used = PlayerAnim.Walking;
            if (vitesse > walkingSpeed)
            {
                used = PlayerAnim.Running; print("Running");
            }
            animController.SetLoopedState(used, "", true);
        }
        else
        {
            animController.SetLoopedState(PlayerAnim.Idle, "", true);
        }
    }
예제 #10
0
 private void Start()
 {
     controller = GetComponent <CharacterController>();
     playerAnim = GetComponent <PlayerAnim>();
     neck       = transform.GetChild(0);
     rot        = transform.eulerAngles;
 }
예제 #11
0
 public void PlayAnim(PlayerAnim anim)
 {
     if (!animator.IsPlaying(animations[anim]))
     {
         animator.Play(animations[anim]);
     }
 }
예제 #12
0
    void Awake()
    {
        controller = this.GetComponent <CharacterController>();
        playerAnim = this.GetComponent <PlayerAnim>();

        targetPosition = transform.position;      //一开始的移动目标为本身,这样才不会进行移动
    }
예제 #13
0
 public void setAnimationRoll(PlayerAnim anim)
 {
     if (controller2D.CanJump())
     {
         animator.SetTrigger("rollTrigger");
     }
 }
예제 #14
0
    override public void Initialize()
    {
        playerAnim = GetComponent <PlayerAnim>();

        if (playerAnim == null)
        {
            Debug.LogError("在" + gameObject.name + "中,没有找到PlayerAnim组件!");
        }

        playerCollider = GetComponent <CapsuleCollider2D>();
        if (playerCollider == null)
        {
            Debug.LogError("在" + gameObject.name + "中,没有找到collider组件!");
        }
        colliderNormalSize   = playerCollider.size;
        colliderNormalOffset = playerCollider.offset;

        CapsuleCollider2D crouchCollider = GameObject.Find("CrouchCollider").GetComponent <CapsuleCollider2D>();

        if (crouchCollider == null)
        {
            Debug.LogError("在" + gameObject.name + "中,没有找到子物体中crouchCollider组件!");
        }
        colliderCrouchOffset = crouchCollider.offset;
        colliderCrouchSize   = crouchCollider.size;

        rigid = GetComponent <Rigidbody2D>();

        detector = GameObject.Find("FloorDetector").GetComponent <OnFloorDetector>();
        if (detector == null)
        {
            Debug.LogError("在" + gameObject.name + "中,没有找到子物体中OnFloorDetector组件!");
        }

        debugInfo1 = GameObject.Find("DebugInfo1").GetComponent <Text>();
        if (debugInfo1 == null)
        {
            Debug.LogError("在" + gameObject.name + "中,没有找到DebugInfo这个ui组件!");
        }
        debugInfo2 = GameObject.Find("DebugInfo2").GetComponent <Text>();
        if (debugInfo2 == null)
        {
            Debug.LogError("在" + gameObject.name + "中,没有找到DebugInfo这个ui组件!");
        }

        //初始化游戏菜单管理组件
        gameMenu = GameObject.Find("GameMenu").GetComponent <GameMenu>();
        if (gameMenu == null)
        {
            Debug.LogError("在" + gameObject.name + "中,没有找到GameMenu");
        }

        //初始化事件管理器
        eventManager = GameObject.Find("EventManager").GetComponent <EventManager>();
        if (eventManager == null)
        {
            Debug.LogError("在" + gameObject.name + "中,没有找到EventManager");
        }
    }
예제 #15
0
 // Use this for initialization
 void Start()
 {
     du    = GameObject.FindObjectOfType <Dungeon>();
     state = Turn.PLAYER_TURN;
     pl    = GameObject.FindObjectOfType <PlayerAnim>();
     en    = GameObject.FindObjectOfType <Enemy>();
     hhh   = GameObject.FindObjectOfType <TouchSerch>();
 }
예제 #16
0
    //*******************************//
    //    MonoBehaviour Functions    //
    //*******************************//

    private void Start()
    {
        m_normalTimeScale = Time.timeScale;
        m_ph    = GetComponent <PlayerHook>();
        m_pa    = GetComponent <PlayerAnim>();
        m_input = GetComponent <PlayerInput>();
        m_pm    = GetComponent <PlayerMovement>();
    }
예제 #17
0
파일: Player.cs 프로젝트: plumwine/Toss
 //アイドル状態
 public void IdleAnim()
 {
     //スペースが押されて、移動を開始したら、アニメーションをRunに変える
     if (Input.IsKeyDown(Keys.Space))
     {
         pAnim = PlayerAnim.Run;
     }
 }
예제 #18
0
 // Start is called before the first frame update
 void Start()
 {
     rigidbody        = GetComponent <Rigidbody2D>();
     playerAnim       = GetComponent <PlayerAnim>();
     spriteRenderer   = transform.GetChild(0).GetComponent <SpriteRenderer>();
     swordArcRenderer = transform.GetChild(1).GetComponent <SpriteRenderer>();
     health           = 4;
 }
예제 #19
0
    void OnTriggerEnter(Collider other)
    {
        if (!offlineMode)
        {
            if (other.gameObject.tag == "Player1" || other.gameObject.tag == "Player2" && !hasCollided)
            {
                if (hasCollided)
                {
                    return;
                }

                //if (other.gameObject == null) return;
                PlayerAnim   panim   = other.gameObject.GetComponent <PlayerAnim>();
                PlayerAttack pAttack = GetComponent <PlayerAttack>();
                PlayerData   pData   = other.GetComponent <PlayerData>();
                if (pAttack == null)
                {
                    pAttack = playerObj.GetComponent <PlayerAttack>();
                }
                if (pData == null)
                {
                    return;
                }
                if (pData.currentHealth <= 0)
                {
                    return;
                }
                if (pAttack.getAttack1)
                {
                    //sound.lightAttackedSound();
                    Debug.Log("Collided with: " + other.gameObject.name);
                    Debug.Log("Player Attack 1: " + pAttack.getAttack1);

                    // if (other.gameObject == null) return;
                    //                PlayerAnimation pa = other.gameObject.GetComponent<PlayerAnimation>();
                    //                if (pa == null) return;
                    panim.lightHit();
                    healthManager.takeDamage(other.gameObject, 10);
                }

                if (pAttack.getAttack2)
                {
                    Debug.Log("Collided with: " + other.gameObject.tag + "  name:" + other.gameObject.name);
                    Debug.Log("Player Attack 2: " + pAttack.getAttack2);

                    //if (other.gameObject == null) return;
                    //                PlayerAnimation pa = other.gameObject.GetComponent<PlayerAnimation>();
                    //                if (pa == null) return;
                    panim.lightHit();
                    healthManager.takeDamage(other.gameObject, 20);
                }

                hasCollided = true;
                StartCoroutine(EnableCollision());
            }
        }
    }
예제 #20
0
 // Start is called before the first frame update
 void Start()
 {
     playerRb     = GetComponent <Rigidbody>();
     cam          = Camera.main;
     playerHeight = transform.position.y;
     playerAnim   = GetComponentInChildren <PlayerAnim>();
     playerHealth = GetComponent <HealthSystem>();
     audioManager = FindObjectOfType <AudioManager>();
 }
예제 #21
0
 void Awake()
 {
     m_anim       = GetComponent <PlayerAnim>();
     m_controller = GetComponent <PlayerController>();
     m_forces     = GetComponent <PlayerForces>();
     m_dev        = GetComponent <PlayerDevToss>();
     m_guide      = GetComponent <PlayerGuideToss>();
     m_stats      = new PlayerStats(m_startHealth);
 }
예제 #22
0
 void Start()
 {
     tr          = GetComponent <Transform>();
     rb          = GetComponent <Rigidbody2D>();
     playerStats = GetComponent <PlayerStats>();
     playerAnim  = GetComponent <PlayerAnim>();
     stick       = FindObjectOfType <Joystick>();
     weapon      = GameObject.Find("Rappier").GetComponent <Rappier>();
 }
예제 #23
0
 protected override void Die()
 {
     PlayerAnim.SetInteger(GlobalVariables.UNIQUE_ANIM_VALUE, GlobalVariables.PLAYER_ANIM_DEATH);
     IgnoreControl = true;
     //GetComponent<CapsuleCollider>().enabled = false;
     gameObject.layer = 0;
     Settings.Instance.Audio.PlayEffect(audioSource, Data.AudioContainer.PlayerSFX.Death);
     //GetComponent<Rigidbody>().isKinematic = true;
 }
예제 #24
0
    public void Ground_Update()
    {
        PlayerAnim currentAnim = PlayerAnim.Idle;

        if (hInput != 0)
        {
            currentAnim = this.objectBeingCarried ? PlayerAnim.Carry_Walk : PlayerAnim.Walk;
        }
        else
        {
            currentAnim = this.objectBeingCarried ? PlayerAnim.Carry_Idle : PlayerAnim.Idle;
        }

        if (!animator.IsPlaying(animations[currentAnim]))
        {
            PlayAnim(currentAnim);
        }
        //END ANIMATION STUFF

        if (objectBeingCarried)
        {
            HandleObjectThrow();
        }
        else
        {
            CheckGrabs();
        }

        this.currentSpeed = this.speed;

        if (Sinput.GetButtonDown("Jump"))
        {
            SfxManager.instance.PlaySound(SoundType.JUMP);
            Squash(0.05f).Then(() => {
                Stretch();
                velocity.y = jumpSpeed;
            });
        }
        if (Sinput.GetButtonDown("Down"))
        {
            if (groundCollider.CompareTag("OneWay"))
            {
                transform.position += Vector3.down * 0.5f;
            }
        }

        this.currentGravityModifier = this.gravityModifier;

        //STATE CHANGES
        if (!grounded)
        {
            fsm.ChangeState(PlayerState.Air);
        }

        HandleLeftRightMovement();
    }
예제 #25
0
 void Start()
 {
     //myCam = GameObject.Find("Main Camera"); //finds the main camera; not necessary right now, maybe later
     playerTransform = gameObject.transform; //sets transform to player transform
     mouseSet        = false;
     portalset       = false;
     portal2set      = false;
     anim            = GetComponent <PlayerAnim>();
     audio           = GetComponent <AudioSource>();
 }
예제 #26
0
 private void Awake()
 {
     _levelData = GetComponent<LevelData>();
     _playerMove = _levelData.Player.GetComponent<PlayerMove>();
     _obstaclesCreator = _levelData.ObstaclesCreatorData.GetComponent<ObstaclesCreator>();
     _progressBar = _levelData.ProgressBar.GetComponent<ProgressBar>();
     _playerInput = _levelData.Player.GetComponent<PlayerInput>();
     _playerCollision = _levelData.Player.GetComponent<PlayerCollision>();
     _playerAnim = _levelData.Player.GetComponent<PlayerAnim>();
 }
예제 #27
0
파일: Player.cs 프로젝트: plumwine/Toss
 //初期化
 public void Initialize()
 {
     barrageSpeed = 0;               //最初は止まっているので0
     tRank        = TimingRank.NULL; //最初は評価無し
     isGameSet    = false;           //最初はゲームが終了していない状態
         pAnim = PlayerAnim.Run;     //最初はIdle状態
     timing  = new Timing();
     isStop  = false;
     isThrow = false;
 }
예제 #28
0
    float reserveMoveHeight;   //移動予定の高さ

    void Start()
    {
        rigid = GetComponent <Rigidbody>();
        pl    = GameObject.FindGameObjectWithTag("Player");
        pig   = GameObject.FindGameObjectWithTag("pigeon");
        pAnim = pig.GetComponent <PlayerAnim>();
        audio = GetComponent <AudioSource>();
        // TODO あとでタイミング変更するかも
        EnableOperation();
    }
예제 #29
0
파일: Player.cs 프로젝트: bia24/LittleHero
    /// <summary>
    /// 是否正在运行目标状态的动画
    /// </summary>
    /// <param name="state"></param>
    /// <returns></returns>
    protected bool IsInAnim(PlayerAnim state)
    {
        string name = null;

        if (!stateAnimNames.TryGetValue(state, out name))
        {
            Debug.LogError("can not find this state anim name");
        }
        return(AnimationController.Instance.IsInStateAnim(name, this));
    }
예제 #30
0
파일: Player.cs 프로젝트: bia24/LittleHero
    /// <summary>
    /// 获得指定动画的长度
    /// </summary>
    /// <param name="state"></param>
    /// <returns></returns>
    protected float GetAnimLength(PlayerAnim state)
    {
        string name = null;

        if (!stateAnimNames.TryGetValue(state, out name))
        {
            Debug.LogError("can not find this state anim name");
        }
        return(AnimationController.Instance.GetAnimtionClipLength(this, name));
    }
예제 #31
0
    private void Start()
    {
        // find high score
        hs = GameObject.FindObjectOfType<HighScore>();
        dm = GameObject.FindObjectOfType<DoorManager>();
        pa = GameObject.FindObjectOfType<PlayerAnim>();

        // setup buttons
        rawInput = new BitArray(6);
        playerValue = ToInt (rawInput);

        playerScore = 0;

        // scale ui to screen
        uiUnit = Screen.height / 5.0f;
        uiStart = (Screen.width / 2.0f) - (uiUnit * 3.0f);

        // setup style for button text
        buttonStyle = new GUIStyle();
        buttonStyle.font = font;
        buttonStyle.fontSize = (int)(0.11f * Screen.height);
        buttonStyle.alignment = TextAnchor.MiddleCenter;

        scoreStyle = new GUIStyle();
        scoreStyle.font = font;
        scoreStyle.fontSize = (int)(0.06f * Screen.height);
        scoreStyle.alignment = TextAnchor.UpperLeft;
        scoreStyle.normal.textColor = Color.white; //Color.cyan;
        scoreStyle.fontStyle = FontStyle.Bold;

        hScoreStyle = new GUIStyle();
        hScoreStyle.font = font;
        hScoreStyle.fontSize = (int)(0.06f * Screen.height);
        hScoreStyle.alignment = TextAnchor.UpperRight;
        hScoreStyle.normal.textColor = Color.white;
        hScoreStyle.fontStyle = FontStyle.Bold;
    }
예제 #32
0
    public void ApplyDeceleration(int playerNum, List<string> keysReleased)
    {
        if (gameManager.IsGamePaused == false && gameManager.IsGameOver == false)
        {
            Vector3 newPosition = gameObject.transform.position;

            if (canMove == true)
            {
                    if (keysReleased.Contains(inputManager.PlayerKeybindArray[inputSourceIndex].UpKey.ToString()) && keysReleased.Contains(inputManager.PlayerKeybindArray[inputSourceIndex].DownKey.ToString()))
                    {
                        if (currentVelocityY > 0)
                        {
                            if (SpeculativeContactsScript.PerformSpeculativeContacts(gameObject.transform.position, Vector2.up * currentDirectionY, height * 1.5f) == true)
                                currentVelocityY = 0;
                            else
                                currentVelocityY -= deceleration * Time.deltaTime;
                        }
                    }

                    if (keysReleased.Contains(inputManager.PlayerKeybindArray[inputSourceIndex].LeftKey.ToString()) && keysReleased.Contains(inputManager.PlayerKeybindArray[inputSourceIndex].RightKey.ToString()))
                    {
                        if (currentVelocityX > 0)
                        {
                            if (SpeculativeContactsScript.PerformSpeculativeContacts(gameObject.transform.position, Vector2.right * currentDirectionX, width * 1.5f) == true)
                                currentVelocityX = 0;
                            else
                                currentVelocityX -= deceleration * Time.deltaTime;
                        }
                    }

                    //If no movement keys are being held, play the idle animation.
                    if (keysReleased.Contains(inputManager.PlayerKeybindArray[inputSourceIndex].UpKey.ToString()) && keysReleased.Contains(inputManager.PlayerKeybindArray[inputSourceIndex].DownKey.ToString())
                        && keysReleased.Contains(inputManager.PlayerKeybindArray[inputSourceIndex].LeftKey.ToString()) && keysReleased.Contains(inputManager.PlayerKeybindArray[inputSourceIndex].RightKey.ToString()))
                    {
                        if (currentAnim != PlayerAnim.Idle) //Play the idle animation if it's not already playing.
                        {
                            currentAnim = PlayerAnim.Idle;
                            UpdateDirectionalAnim();
                        }
                    }
            }

            if (keysReleased.Contains(inputManager.PlayerKeybindArray[inputSourceIndex].UpKey.ToString()) || keysReleased.Contains(inputManager.PlayerKeybindArray[inputSourceIndex].DownKey.ToString())
                        || keysReleased.Contains(inputManager.PlayerKeybindArray[inputSourceIndex].LeftKey.ToString()) || keysReleased.Contains(inputManager.PlayerKeybindArray[inputSourceIndex].RightKey.ToString()))
            {
                if (currentVelocityX < 0)
                    currentVelocityX = 0;
                if (currentVelocityY < 0)
                    currentVelocityY = 0;

                newPosition.x += currentVelocityX * currentDirectionX * Time.deltaTime;
                newPosition.y += currentVelocityY * currentDirectionY * Time.deltaTime;
                gameObject.transform.position = newPosition;
            }
        }
    }
예제 #33
0
    public void PlayerControllerInput(int playerNum, Vector2 thumbstickVector)
    {
        if (playerNum == inputSourceIndex)
        {
            if (gameManager.IsGamePaused == false && gameManager.IsGameOver == false)
            {
                Vector3 newPosition = gameObject.transform.position;

                if (canMove == true)
                {
                        //================================================ MOVEMENT ================================================
                    if (thumbstickVector.y >= THUMBSTICK_TRIGGER_DEADZONE || thumbstickVector.y <= -THUMBSTICK_TRIGGER_DEADZONE)
                    {
                        if (thumbstickVector.y > 0)
                        {
                            currentDirectionY = 1;
                            currentDirection = Direction.Up;
                        }

                        if (thumbstickVector.y < 0)
                        {
                            currentDirectionY = -1;
                            currentDirection = Direction.Down;
                        }
                    }
                    else
                        currentDirectionY = 0;

                    if (thumbstickVector.x >= THUMBSTICK_TRIGGER_DEADZONE || thumbstickVector.x <= -THUMBSTICK_TRIGGER_DEADZONE)
                    {
                        if (thumbstickVector.x > THUMBSTICK_TRIGGER_DEADZONE)
                        {
                            currentDirectionX = 1;
                            currentDirection = Direction.Right;
                        }

                        if (thumbstickVector.x < THUMBSTICK_TRIGGER_DEADZONE)
                        {
                            currentDirectionX = -1;
                            currentDirection = Direction.Left;
                        }
                    }
                    else
                        currentDirectionX = 0;

                    //Only call PlayerMove() if the thumbstick isn't completely idle.
                    if (((thumbstickVector.y >= THUMBSTICK_TRIGGER_DEADZONE || thumbstickVector.y <= -THUMBSTICK_TRIGGER_DEADZONE)) ||
                        (thumbstickVector.x >= THUMBSTICK_TRIGGER_DEADZONE || thumbstickVector.x <= -THUMBSTICK_TRIGGER_DEADZONE))
                    {
                        PlayerMove(currentDirectionX, currentDirectionY);

                        if (currentAnim != PlayerAnim.Walk) //Move the player and play an animation based on the current direction
                        {
                            currentAnim = PlayerAnim.Walk;
                            UpdateDirectionalAnim();
                        }
                    }
                    else //If the thumbstick is idle, play the idle animation.
                    {
                        if (currentAnim != PlayerAnim.Idle) //Move the player and play an animation based on the current direction
                        {
                            currentAnim = PlayerAnim.Idle;
                            UpdateDirectionalAnim();
                        }
                    }
                }
            }
        }
    }
예제 #34
0
 private void SetBlendWeight(PlayerAnim anim, float px)
 {
     animation[PlayerAnimName[(int)anim]].weight = px;
 }
예제 #35
0
    private void PlayOneShot(PlayerAnim oneShotAnim)
    {
        if (_oneShotState != OneShotState.None)
        {
            return;
        }

        _oneShotState = OneShotState.BlendIn;
        _currentOnShotAnim = oneShotAnim;

        var animClip = animation[PlayerAnimName[(int)oneShotAnim]];

        animClip.normalizedTime = 0;
        animClip.speed = 0;

        RecordBlendWeights();
    }
예제 #36
0
    public void PlayerInput(int playerNum, List<string> keysHeld)
    {
        if (gameManager.IsGamePaused == false && gameManager.IsGameOver == false)
        {
            Vector3 newPosition = gameObject.transform.position;

            if (canMove == true)
            {
                    //================================================ MOVEMENT ================================================
                    if (keysHeld.Contains(inputManager.PlayerKeybindArray[inputSourceIndex].UpKey.ToString()) || keysHeld.Contains(inputManager.PlayerKeybindArray[inputSourceIndex].DownKey.ToString()) ||
                        (keysHeld.Contains(inputManager.PlayerKeybindArray[inputSourceIndex].LeftKey.ToString()) || keysHeld.Contains(inputManager.PlayerKeybindArray[inputSourceIndex].RightKey.ToString())))
                    {
                        if (keysHeld.Contains(inputManager.PlayerKeybindArray[inputSourceIndex].UpKey.ToString()) || keysHeld.Contains(inputManager.PlayerKeybindArray[inputSourceIndex].DownKey.ToString()))
                        {

                            if (keysHeld.Contains(inputManager.PlayerKeybindArray[inputSourceIndex].UpKey.ToString()) )
                            {
                                currentDirectionY = 1;
                                currentDirection = Direction.Up;
                            }
                            else if (keysHeld.Contains(inputManager.PlayerKeybindArray[inputSourceIndex].DownKey.ToString()) ) //Can no longer do a simple else because of the animation.
                            {
                                currentDirectionY = -1;
                                currentDirection = Direction.Down;
                            }
                        }

                        if (keysHeld.Contains(inputManager.PlayerKeybindArray[inputSourceIndex].LeftKey.ToString()) || keysHeld.Contains(inputManager.PlayerKeybindArray[inputSourceIndex].RightKey.ToString()))
                        {
                            if (keysHeld.Contains(inputManager.PlayerKeybindArray[inputSourceIndex].LeftKey.ToString()) )
                            {
                                currentDirectionX = -1;
                                currentDirection = Direction.Left;
                            }
                            else if (keysHeld.Contains(inputManager.PlayerKeybindArray[inputSourceIndex].RightKey.ToString()) ) //Can no longer do a simple else because of the animation.
                            {
                                currentDirectionX = 1;
                                currentDirection = Direction.Right;
                            }
                        }
                        //Move the player and play an animation based on the current direction
                        PlayerMove(currentDirectionX, currentDirectionY);

                        if (currentAnim != PlayerAnim.Walk)
                        {
                            currentAnim = PlayerAnim.Walk;
                            UpdateDirectionalAnim();
                        }
                    }
                        //=================================================================================================================

                        //================================================ BEAM FUNCTIONALITY AND ABILITY ================================================
                    if (keysHeld.Contains(inputManager.PlayerKeybindArray[inputSourceIndex].LTurnKey.ToString()) || keysHeld.Contains(inputManager.PlayerKeybindArray[inputSourceIndex].RTurnKey.ToString()))
                        {
                            if (keysHeld.Contains(inputManager.PlayerKeybindArray[inputSourceIndex].LTurnKey.ToString()))
                                RotateBeamKeyboard(1);
                            else
                                RotateBeamKeyboard(-1);
                        }

                    if (keysHeld.Contains(inputManager.PlayerKeybindArray[inputSourceIndex].GraborThrowKey.ToString()))
                        {
                            if (canPerformAction == true)
                            {
                                if (selectorBeam.GetComponent<BeamScript>().IsHoldingObject == false)
                                    GrabObject();
                                else
                                    ThrowObject();
                            }
                        }
                    if (keysHeld.Contains(inputManager.PlayerKeybindArray[inputSourceIndex].AbilityKey.ToString()))
                    {
                        UseActive();
                    }
                        //=================================================================================================================
            }
        }
    }