Esempio n. 1
0
    void Start()
    {
        Instance = this;

        Sphere.SetActive(true);
        whichChar = 0;


        target = Sphere.transform;
    }
Esempio n. 2
0
 protected void BaseStart()
 {
     playerTrans    = this.transform.parent.GetComponent <Transform>();
     animator       = GetComponent <Animator>();
     playerEnergy   = GetComponentInParent <PlayerEnergy>();
     playerControl  = GetComponentInParent <PlayerControl>();
     playerChange   = GetComponentInParent <PlayerChange>();
     spriteRenderer = GetComponent <SpriteRenderer>();
     playerCollider = GetComponentInParent <Collider2D>();
     attackTrigger  = this.transform.GetChild(0).GetComponent <CircleCollider2D>();
     enemyFilter.SetLayerMask(LayerMask.GetMask("Enemy"));
     canAtkObjFilter.SetLayerMask(LayerMask.GetMask("CanAtkObj"));
 }
Esempio n. 3
0
    //[Header("按鍵UI切換")]  //keyboard按鍵和joystick按鍵
    //public GameObject keyboardButtonGroup;
    //public GameObject joystickButtonGroup;
    //private bool isKeyboardInput = true;


    void Start()
    {
        playerChange = transform.parent.GetComponent <PlayerChange>();

        WheelCanvas       = GetComponent <CanvasGroup>();
        WheelCanvas.alpha = 0f;

        for (int i = 0; i < 3; i++)
        {
            selected_light[i] = transform.GetChild(0).transform.GetChild(i).gameObject; selected_light[i].SetActive(false);
        }

        /*for (int i = 0; i < 3; i++)
         * {
         *  input_arrows_UI[i] = transform.GetChild(2).GetChild(0).GetChild(i).gameObject; input_arrows_UI[i].SetActive(false);
         *  input_buttons_UI[i] = transform.GetChild(2).GetChild(1).GetChild(i).gameObject; input_buttons_UI[i].SetActive(false);
         * }*/

        //SetButtonUIState(isKeyboardInput);
    }
Esempio n. 4
0
    void Awake()
    {
        rb2d         = GetComponent <Rigidbody2D>();
        playerEnergy = this.GetComponent <PlayerEnergy>();
        playerChange = this.GetComponent <PlayerChange>();

        footCheck  = transform.Find("footPoint");
        frontCheck = transform.Find("frontPoint");
        backCheck  = transform.Find("backPoint");

        for (int x = 0; x < 3; x++)
        {
            //Transform child = this.transform.GetChild(x);
            spriteRenderer[x] = this.transform.GetChild(x).GetComponent <SpriteRenderer>();
            animator[x]       = this.transform.GetChild(x).GetComponent <Animator>();

            skill_Base[x] = this.transform.GetChild(x).GetComponent <Skill_Base>();
        }
        skill_Water = this.transform.GetChild(1).GetComponent <Skill_Water>();

        speedLimit = initSpeedLimit;

        //---各種圖層MASK設定---
        whatIsGround   = LayerMask.GetMask("Ground & Wall");
        whatIsPlatform = LayerMask.GetMask("Platform");

        //---NoticeMark--
        noticeUIControl = this.transform.Find("noticeUI_folder").GetComponent <NoticeUIControl>();

        //NoticeUI_Setting(999);

        //---bubble maker init---
        bubbleMaker = transform.Find("BubbleMaker").GetComponent <ParticleSystem>();
        bubbleMaker.Stop();

        //---用於髒污ripple的材質遮罩設定---
        rippleMask = this.transform.Find("DirtyRipple_Mask").GetComponent <SpriteMask>();
    }
Esempio n. 5
0
 private void Awake()
 {
     _instance = this;
 }
Esempio n. 6
0
 public Task SavePlayer(Player player, PlayerChange changes)
 => Task.CompletedTask;
Esempio n. 7
0
    void FixedUpdate()
    {
        //LogState();
        #region GENERAL BEHAVIOUR

        #region RICK HORIZONTAL MOVEMENT
        if (!stop)
        {
            if (InputManager.MainHorizontal() > 0.0f && !GetComponent <PlayerGround>().RightHit)
            {
                GetComponent <PlayerMovement>().MoveRight();
            }
            else if (InputManager.MainHorizontal() == 0.0f)
            {
                GetComponent <PlayerMovement>().Stop();
            }
            else if (InputManager.MainHorizontal() < 0.0f & !GetComponent <PlayerGround>().LeftHit)
            {
                GetComponent <PlayerMovement>().MoveLeft();
            }
        }
        #endregion

        #region RICK GROUNDING
        if (State != MyState.Grounding && GetComponent <PlayerGround>().CheckGround())
        {
            StartCoroutine(ActiveGrounding());                                                  //Controls if Rick is on the ground
        }
        #endregion

        #region RICK DASH
        if (InputManager.ButtonX)
        {
            if (GetComponent <PlayerDash>().enabled)
            {
                InputManager.ButtonX = false;

                if (GetComponent <PlayerDash>().CheckDash())
                {
                    GetComponent <PlayerDash>().Dash();
                    source.PlayOneShot(dashSound, DefaultValues.Volume.Dash);
                    LastState = State;
                    State     = MyState.Dashing;
                }
            }
        }
        #endregion

        #region RICK CHANGE CHARACTER
        if (InputManager.ButtonY)
        {
            PlayerChange playerChange = GetComponent <PlayerChange>();

            if (playerChange.enabled)
            {
                InputManager.ButtonY = false;                                                   //Allows Rick to change between Square and Circle

                playerChange.Change();
                playerChange.Actualize();
            }
        }
        #endregion

        #region RICK GHOST
        if (InputManager.ButtonB)
        {
            PlayerGhost playerGhost = GetComponent <PlayerGhost>();

            if (playerGhost.enabled)
            {
                InputManager.ButtonB = false;

                if (playerGhost.CheckGhost())
                {
                    if (playerGhost.CheckTeleport())
                    {
                        playerGhost.Teleport();

                        // Change character to the ghost one and actualize the properties.
                        Character = playerGhost.GhostChar;
                        GetComponent <PlayerChange>().Actualize();
                    }
                }
                else
                {
                    playerGhost.Create();
                }
            }
        }
        #endregion

        #endregion

        #region CIRCLE BEHAVIOR
        //Circle properties and habilities
        if (Character == MyCharacter.CIRCLE)
        {
            #region Bouncing

            //Checks if the player can bounce on the floor
            if (GetComponent <PlayerBounce>().CheckBounce())
            {
                if (!StopBounce)
                {
                    StartCoroutine(GetComponent <PlayerBounce>().NormalBounce());
                    source.PlayOneShot(jumpSound, DefaultValues.Volume.Bounce);
                    LastState = State;
                    StartCoroutine(ActiveBouncing());
                }
            }
            #endregion

            #region Wall Bouncing
            //Checks if the player can bounce in a wall in both sides
            if (GetComponent <PlayerBounce>().CheckWallBounce())
            {
                if (!StopWallBounce)
                {
                    StartCoroutine(GetComponent <PlayerBounce>().WalledBounce());
                    source.PlayOneShot(jumpSound, DefaultValues.Volume.Bounce);
                }
            }
            #endregion

            #region Jumping
            if (InputManager.ButtonA)
            {
                InputManager.ButtonA = false;

                if (GetComponent <PlayerJump>().enabled)
                {
                    //Checks the current player state in order to distinguish between a jump and a double jump
                    switch (State)
                    {
                    case MyState.Grounding:
                        GetComponent <PlayerJump>().Jump();
                        source.PlayOneShot(jumpSound, DefaultValues.Volume.Jump);
                        LastState = State;
                        State     = MyState.Jumping;
                        break;

                    case MyState.Jumping:
                        GetComponent <PlayerJump>().DoubleJump();
                        source.PlayOneShot(jumpSound, DefaultValues.Volume.Jump);
                        LastState = State;
                        State     = MyState.DoubleJumping;
                        break;
                    }
                }
            }
            #endregion
        }
        #endregion

        #region SQUARE BEHAVIOR
        // Square properties and habilities
        else if (Character == MyCharacter.SQUARE)
        {
            #region Jumping & Falling
            if (InputManager.ButtonA)
            {
                InputManager.ButtonA = false;

                if (GetComponent <PlayerJump>().enabled)
                {
                    // Checks the player state in order to Smack or Jump,
                    // as both habilities are triggered by the same button.
                    switch (State)
                    {
                    case MyState.Grounding:
                    case MyState.Climbing:
                        GetComponent <PlayerJump>().Jump();
                        source.PlayOneShot(jumpSound, DefaultValues.Volume.Jump);
                        LastState = State;
                        State     = MyState.Jumping;
                        break;

                    case MyState.Jumping:
                    case MyState.DoubleJumping:
                    case MyState.Bouncing:
                        if (!GetComponent <PlayerGround>().LeftHit&& !GetComponent <PlayerGround>().RightHit)
                        {
                            GetComponent <PlayerFall>().Fall();
                            LastState = State;
                            State     = MyState.Falling;

                            // Spawn dust particles after falling.
                            StartCoroutine(SpawnDust());
                        }
                        break;
                    }
                }
            }
            #endregion

            #region Wall Climbing
            if (GetComponent <PlayerClimb>().enabled)
            {
                if (!stop && (GetComponent <PlayerGround>().LeftHit || GetComponent <PlayerGround>().RightHit) && State != MyState.Falling)
                {
                    if (GetComponent <PlayerGround>().LeftHit != GetComponent <PlayerGround>().RightHit)
                    {
                        if (!GetComponent <PlayerGround>().Grounded)
                        {
                            LastState = State;
                            State     = MyState.Climbing;
                        }
                        GetComponent <PlayerClimb>().Climb();
                    }
                }
            }
            #endregion
        }
        #endregion
    }