コード例 #1
0
ファイル: Player.cs プロジェクト: FourSwordKirby/Underwater
    public void hideControl()
    {
        //Jump controls
        if (Controls.JumpInputDown())
        {
            if (InstructionSprite.sprite == potentialInstructionSprites[0] && this.grounded == false)
            {
                InstructionSprite.gameObject.SetActive(false);
            }
        }

        //Shooting controls
        if (Controls.ShootInputHeld() && activeWeapon != null && isUnderWater)
        {
            if (InstructionSprite.sprite == potentialInstructionSprites[1])
            {
                InstructionSprite.gameObject.SetActive(false);
            }
        }

        //Switching Weapons Controls
        if (Controls.PrevWeaponInputDown() || Controls.NextWeaponInputDown())
        {
            if (InstructionSprite.sprite == potentialInstructionSprites[2])
            {
                InstructionSprite.gameObject.SetActive(false);
            }
        }

        //aim controls
        if (Controls.AimDownInputHeld() || Controls.AimUpInputHeld())
        {
            if (InstructionSprite.sprite == potentialInstructionSprites[3])
            {
                InstructionSprite.gameObject.SetActive(false);
            }
        }

        if (InstructionSprite.sprite == potentialInstructionSprites[4])
        {
            InstructionSprite.gameObject.SetActive(false);
        }
    }
コード例 #2
0
ファイル: Player.cs プロジェクト: FourSwordKirby/Underwater
    // Update is called once per frame
    void Update()
    {
        this.ActionFsm.Execute();
        this.spriteRenderer = this.anim.GetComponent <SpriteRenderer>();

        if (invulnTime > 0)
        {
            invulnTime -= Time.deltaTime;

            Debug.Log((int)(invulnTime / (baseInvulnTime * 0.125)));

            if ((int)(invulnTime / (baseInvulnTime * 0.125)) % 2 == 1)
            {
                this.spriteRenderer.color = Color.red;
            }
            if ((int)(invulnTime / (baseInvulnTime * 0.125)) % 2 == 0)
            {
                this.spriteRenderer.color = Color.white;
            }

            this.environmentCollisionBox.gameObject.layer = LayerMask.NameToLayer("Invuln");
            this.hitboxManager.deactivateAllHitboxes();


            if (invulnTime <= 0)
            {
                this.environmentCollisionBox.gameObject.layer = LayerMask.NameToLayer("Player");
                this.hitboxManager.activateAllHitboxes();
            }
        }

        if (inCutscene)
        {
            return;
        }
        //Animation control stuff
        Vector2 movementInputVector = Controls.getDirection();

        //Controlling where we are aiming
        this.aim = Parameters.VectorToAim(movementInputVector);
        if (this.grounded && this.aim == Parameters.Aim.Down)
        {
            this.aim = Parameters.Aim.TiltDown;
        }
        if (Controls.AimDownInputHeld())
        {
            this.aim = Parameters.Aim.TiltDown;
        }
        if (Controls.AimUpInputHeld())
        {
            this.aim = Parameters.Aim.TiltUp;
        }


        //Controlling the direction we are facing
        if (movementInputVector.x != 0 && !lockedDir)
        {
            this.direction = Parameters.VectorToDir(movementInputVector);
        }

        this.anim.SetFloat("Direction", Parameters.GetDirAnimation(this.direction));
        this.anim.SetFloat("Aim", Parameters.GetAimAnimation(this.aim));

        //Syncing the anims
        SyncAnims();

        //Shooting controls
        if (Controls.ShootInputHeld() && activeWeapon != null)
        {
            if (isUnderWater)
            {
                activeWeapon.Fire(direction, aim);
            }
            else
            {
                AudioSource.PlayClipAtPoint(audio[0], transform.position);
                //Do another indicator you can't fire
            }
            LockDirection();
        }
        else
        {
            activeWeapon.CeaseFire();
            if (grounded)
            {
                UnlockDirection();
            }
        }

        //Switching Weapons Controls
        if (Controls.PrevWeaponInputDown())
        {
            AudioSource.PlayClipAtPoint(audio[1], transform.position);
            SwitchWeapons(currentWeaponIndex - 1);
        }
        if (Controls.NextWeaponInputDown())
        {
            AudioSource.PlayClipAtPoint(audio[1], transform.position);
            SwitchWeapons(currentWeaponIndex + 1);
        }

        //Interacting Controls
        if (Controls.InteractInputDown() && currentInteractable != null)
        {
            currentInteractable.Interact(this);
        }

        //Toggle controls (for weights and related things)
        if (hasWeights && Controls.Toggle1Down())
        {
            if (isWeighted)
            {
                AudioSource.PlayClipAtPoint(audio[3], transform.position);
            }
            else
            {
                AudioSource.PlayClipAtPoint(audio[2], transform.position);
            }

            isWeighted = !isWeighted;

            SetAnimator();
        }

        //Contextual visuals
        if (currentInteractable != null && !inCutscene)
        {
            showControl(PlayerControls.Interact);
        }
        else

        //Try to hide controls if they are visible
        if (InstructionSprite.gameObject.activeSelf)
        {
            hideControl();
        }
    }