Пример #1
0
    protected void RpcOnCatSpecial(CatSpecial special)
    {
        if (isLocalPlayer)
        {
            return;
        }

        dash.Play();
        StartCoroutine(DisableDelayed(dash, special.duration));
    }
Пример #2
0
 protected void CmdOnCatSpecial(CatSpecial special)
 {
     catSpecial = special;
 }
Пример #3
0
    public override void OnSpecialExec(Player player, float time)
    {
        if (playerType == PlayerType.Platipus)
        {
            if (Time.timeSinceLevelLoad - specialEnterTime < 0.3f)
            {
                rigidBody.velocity = Vector2.zero;
            }
            else
            {
                if (!IsGrounded())
                {
                    rigidBody.velocity = new Vector2(0, -15);
                    //specialStarted = true;
                }
                else
                {
                    if (specialEndTime == 0 && IsGrounded())
                    {
                        transform.Find("Dirt").GetComponent <ParticleSystem>().Play();
                        GetComponent <CameraController>().Shake(0.045f, 0.08f);
                        rigidBody.velocity = new Vector2(0, 0);

                        Collider2D[] nearPlayers = Physics2D.OverlapCircleAll(this.transform.position, 1.4f);

                        for (int i = 0; i < nearPlayers.Length; i++)
                        {
                            if (nearPlayers[i].gameObject != this.gameObject && nearPlayers[i].gameObject.layer == gameObject.layer)
                            {
                                Player current = nearPlayers[i].GetComponent <Player>();

                                Vector2 heading = (nearPlayers[i].transform.position - transform.position);
                                float   mag     = heading.magnitude;
                                Vector2 dir     = heading / mag;

                                float force = Mathf.Clamp(0.8f - mag, 0, 0.8f) / 0.8f * 10 + 2;

                                CmdAddForce(current.playerName, dir * force + new Vector2(0, 10 * Mathf.Clamp(0.8f - mag, 0, 0.8f) / 0.8f + 2));
                            }
                        }
                        AudioManager.Instance.Play("baseball_hitbat", 0.4f);


                        PlatipusSpecial special = new PlatipusSpecial();
                        special.time     = Time.timeSinceLevelLoad;
                        special.position = this.transform.position;
                        CmdOnPlatipusSpecial(special);

                        specialEndTime = Time.timeSinceLevelLoad;
                    }
                    else if (specialEndTime != 0 && Time.timeSinceLevelLoad - specialEndTime > 0.35f)
                    {
                        playerState.State = PlayerStates.Idle;
                    }
                }
            }
        }
        else if (playerType == PlayerType.TRex)
        {
            if (Time.timeSinceLevelLoad - specialEnterTime < 0.2f)
            {
                rigidBody.velocity = Vector2.zero;
            }
            else
            {
                if (!specialStarted)
                {
                    specialStarted                   = true;
                    fireBall.transform.parent        = transform.Find("Player_platy_head");
                    fireBall.transform.localPosition = fireBallInitialPos;
                    fireBall.transform.parent        = null;
                    fireBall.gameObject.SetActive(true);
                    fireBall.Play();
                }
                else if (specialStarted && specialEndTime == 0)
                {
                    GetComponent <CameraController>().Shake(0.025f, 0.06f);
                    fireBall.GetComponent <FireBall>().Shoot(new Vector2(transform.localEulerAngles.y == 180 ? 1 : -1, 0));
                    specialEndTime = Time.timeSinceLevelLoad;

                    TRexSpecial special = new TRexSpecial();
                    special.time     = Time.timeSinceLevelLoad;
                    special.position = this.transform.position;
                    special.dir      = new Vector2(transform.eulerAngles.y == 180 ? 1 : -1, 0);
                    CmdOnTRexSpecial(special);
                    AudioManager.Instance.Play("death_fire2", 0.4f);
                }
                else if (specialEndTime != 0 && Time.timeSinceLevelLoad - specialEndTime > 0.5f)
                {
                    if (IsGrounded())
                    {
                        playerState.State = PlayerStates.Idle;
                    }
                    else
                    {
                        playerState.State = PlayerStates.Falling;
                    }
                }
            }
        }
        else if (playerType == PlayerType.Cat)
        {
            if (Time.timeSinceLevelLoad - specialEnterTime < 0.2f)
            {
                rigidBody.velocity = Vector2.zero;
                specialDir         = transform.localEulerAngles.y == 180 ? 1 : -1;
            }
            else
            {
                //float rotation = Mathf.Atan2(specialDir.y, Mathf.Abs(specialDir.x)) * 180 / Mathf.PI;
                //this.transform.eulerAngles = new Vector3(transform.eulerAngles.x, transform.eulerAngles.y, -rotation);
                //rigidBody.velocity = specialDir * 15;
                rigidBody.velocity = specialDir * Vector2.right * 15;

                if (!specialStarted)
                {
                    specialStarted     = true;
                    specialEndTime     = Time.timeSinceLevelLoad;
                    autoAdjustRotation = false;
                    AudioManager.Instance.Play("ig_cat", 0.5f);

                    CatSpecial special = new CatSpecial();
                    special.time     = Time.timeSinceLevelLoad;
                    special.duration = 0.2f;
                    CmdOnCatSpecial(special);
                }
                else if (specialStarted)
                {
                    if (Time.timeSinceLevelLoad - specialEndTime > 0.12f)
                    {
                        rigidBody.velocity = Vector2.zero;
                        autoAdjustRotation = true;
                        dash.Stop();

                        if (IsGrounded())
                        {
                            playerState.State = PlayerStates.Idle;
                        }
                        else
                        {
                            playerState.State = PlayerStates.Falling;
                        }
                    }
                    else
                    {
                        Collider2D[] nearPlayers = Physics2D.OverlapCircleAll(this.transform.position, 0.45f);

                        for (int i = 0; i < nearPlayers.Length; i++)
                        {
                            if (nearPlayers[i].gameObject != this.gameObject && nearPlayers[i].gameObject.layer == gameObject.layer)
                            {
                                Player current = nearPlayers[i].GetComponent <Player>();

                                CmdAddForce(current.playerName, rigidBody.velocity + new Vector2(0, 2));
                            }
                        }
                    }
                }
            }
        }
    }