Exemplo n.º 1
0
 void Start()
 {
     state                  = GetComponent <Player_State>();
     animator               = GetComponent <Player_Animator>();
     timers                 = GetComponent <Player_Timers>();
     attributes             = state.attributes;
     speedManager           = GetComponent <Speed_Manager>();
     velocity               = speedManager.velocity;
     jumpCount              = state.jumpCount;
     onGround               = state.onGround;
     onWall                 = state.onWall;
     control                = state.control;
     wantToJump             = state.wantToJump;
     wallSliding            = state.wallSliding;
     wallClimbing           = state.wallClimbing;
     wallJumping            = state.wallJumping;
     stunned                = state.stunned;
     sign                   = state.sign;
     wallSign               = state.wallSign;
     jumpBufferTimer        = timers.jumpBufferTimer;
     wallStickTimer         = timers.wallStickTimer;
     wallClimbTimer         = timers.wallClimbTimer;
     wallClimbCooldownTimer = timers.wallClimbCooldownTimer;
     wallJumpTimer          = timers.wallJumpTimer;
     wallJumpCooldownTimer  = timers.wallJumpCooldownTimer;
     moveSpeed              = attributes.moveSpeed;
     wallSlideSpeed         = attributes.wallSlideSpeed;
     wallClimbVel           = attributes.wallClimbVel;
     wallJumpVel            = attributes.wallJumpVel;
     wallStickCooldown      = attributes.wallStickCooldown;
     wallClimbCooldown      = attributes.wallClimbCooldown;
     wallClimbTime          = attributes.wallClimbTime;
     wallJumpCooldown       = attributes.wallJumpCooldown;
     wallJumpTime           = attributes.wallJumpTime;
 }
Exemplo n.º 2
0
    // Oponent control
    void Case_Oponent_Attack()
    {
        actualVelocityPlayer = transform.forward * 5.0f * Time.deltaTime;
        animation.Play("running_ball");
        Vector3 RelativeWaypointPosition = transform.InverseTransformPoint(goalPosition.position);

        inputSteer = RelativeWaypointPosition.x / RelativeWaypointPosition.magnitude;
        transform.Rotate(0, inputSteer * 10.0f, 0);
        float staminaTemp = Mathf.Clamp((stamina / STAMINA_DIVIDER), STAMINA_MIN, STAMINA_MAX);

        transform.position += transform.forward * 4.0f * Time.deltaTime * staminaTemp * Speed;

        timeToPass -= Time.deltaTime;

        if (timeToPass < 0.0f && NoOneInFront(oponents))
        {
            timeToPass = UnityEngine.Random.Range(1.0f, 5.0f);
            state      = Player_State.PASSING;
            animation.Play("pass");
            timeToBeSelectable     = 1.0f;
            temporallyUnselectable = true;
        }

        float   distance = (goalPosition.position - transform.position).magnitude;
        Vector3 relative = transform.InverseTransformPoint(goalPosition.position);

        if (distance < 20.0f && relative.z > 0)
        {
            state = Player_State.SHOOTING;
            animation.Play("shoot");
            timeToBeSelectable     = 1.0f;
            temporallyUnselectable = true;
        }
    }
Exemplo n.º 3
0
 void Start()
 {
     rb             = GetComponent <Rigidbody2D>();
     state          = GetComponent <Player_State>();
     animator       = GetComponent <Player_Animator>();
     timers         = GetComponent <Player_Timers>();
     attributes     = state.attributes;
     speedManager   = GetComponent <Speed_Manager>();
     velocity       = speedManager.velocity;
     onGround       = state.onGround;
     onWall         = state.onWall;
     onSlope        = state.onSlope;
     onQuicksand    = state.onQuicksand;
     airborne       = state.airborne;
     control        = state.control;
     pivoting       = state.pivoting;
     dashing        = state.dashing;
     sprinting      = state.sprinting;
     input          = state.input;
     sign           = state.sign;
     prevSign       = state.prevSign;
     pivotSign      = state.pivotSign;
     pivotTimer     = timers.pivotTimer;
     momentumTimer  = timers.momentumTimer;
     moveSpeed      = attributes.moveSpeed;
     momentumFactor = attributes.momentumFactor;
     pivotTime      = attributes.pivotTime;
     momentumTime   = attributes.momentumTime;
     rb.drag        = attributes.rbDrag;
     rb.mass        = attributes.rbMass;
     gravity        = attributes.gravity;
 }
Exemplo n.º 4
0
 void Start()
 {
     state             = GetComponent <Player_State>();
     animator          = GetComponent <Player_Animator>();
     timers            = GetComponent <Player_Timers>();
     attributes        = state.attributes;
     speedManager      = GetComponent <Speed_Manager>();
     leftWallCheck     = gameObject.transform.GetChild(2).gameObject.GetComponent <WallCheck>();
     rightWallCheck    = gameObject.transform.GetChild(3).gameObject.GetComponent <WallCheck>();
     velocity          = speedManager.velocity;
     onWall            = state.onWall;
     control           = state.control;
     dashing           = state.dashing;
     dashReady         = state.dashReady;
     dashAttacking     = state.dashAttacking;
     stunned           = state.stunned;
     input             = state.input;
     dashDir           = state.dashDir;
     dash              = state.dash;
     dashCooldownTimer = timers.dashCooldownTimer;
     dashAttackTimer   = timers.dashCooldownTimer;
     dashTimer         = timers.dashTimer;
     momentumTimer     = timers.momentumTimer;
     moveSpeed         = attributes.moveSpeed;
     dashSpeed         = attributes.dashSpeed;
     dashCooldownTime  = attributes.dashCooldownTime;
     dashTime          = attributes.dashTime;
     dashAttackTime    = attributes.dashAttackTime;
     momentumTime      = attributes.momentumTime;
     collisionMask     = attributes.collisionMask;
 }
Exemplo n.º 5
0
    void OnCollisionStay(Collision coll)
    {
        if (coll.collider.transform.gameObject.tag == "Ball" && !gameObject.GetComponent <Player_Script>().temporallyUnselectable)
        {
            inGame.lastTouched = gameObject;
            if (state == Player_State.TACKLE)
            {
                sphere.transform.position += transform.forward;
            }

            Vector3 relativePos = transform.InverseTransformPoint(sphere.gameObject.transform.position);

            // only "glue" the ball to player if the collision is at bottom
            if (relativePos.y < 0.35f)
            {
                coll.rigidbody.rotation = Quaternion.identity;
                GameObject ball = coll.collider.transform.gameObject;
                ball.GetComponent <Sphere>().owner = gameObject;

                if (gameObject.tag == "OponentTeam")
                {
                    state = Player_Script.Player_State.OPONENT_ATTACK;
                }
            }
        }
    }
Exemplo n.º 6
0
    public IEnumerator EnemyRunning(bool tick)
    {
        while (currentState == Player_State.RUNNING)
        {
            while (tick)
            {
                if (mov.collide)
                {
                    if (mov.health > 0)
                    {
                        tick    = false;
                        mov.pos = true;

                        CurrentState = Player_State.DEAD;
                    }

                    else
                    {
                        tick    = false;
                        mov.pos = true;

                        CurrentState = Player_State.GAMEOVER;
                    }
                }
            }
        }
        yield return(null);
    }
Exemplo n.º 7
0
 void Start()
 {
     rb            = GetComponent <Rigidbody2D>();
     state         = GetComponent <Player_State>();
     animator      = GetComponent <Player_Animator>();
     timers        = GetComponent <Player_Timers>();
     attributes    = state.attributes;
     wallActions   = GetComponent <Player_Wall_Actions>();
     pJump         = GetComponent <Player_Jump>();
     pDash         = GetComponent <Player_Dash>();
     pDive         = GetComponent <Player_Dive>();
     pCol          = GetComponent <Player_Collisions>();
     pAttack       = GetComponent <Player_Attack>();
     move          = GetComponent <Player_Move>();
     playerManager = GetComponent <PlayerManager>();
     rb.drag       = 0.5f;
     rb.mass       = 1.5f;
     ReceiveValues();
     moveSpeed          = attributes.moveSpeed;
     jumpVelocity       = attributes.jumpVelocity;
     maxDescendAngle    = attributes.maxDescendAngle;
     dashSpeed          = attributes.dashSpeed;
     momentumFactor     = attributes.momentumFactor;
     wallSlideSpeed     = attributes.wallSlideSpeed;
     pivotTime          = attributes.pivotTime;
     diveAttackTime     = attributes.diveAttackTime;
     momentumTime       = attributes.momentumTime;
     wallStickCooldown  = attributes.wallStickCooldown;
     terminalVel        = new Vector2(dashSpeed / 2.0f, dashSpeed / 2.5f);
     airTerminalVel     = new Vector2(dashSpeed / 3.0f, dashSpeed);
     slopeCollisionMask = attributes.slopeCollisionMask;
     gravity            = attributes.gravity;
 }
Exemplo n.º 8
0
 void Start()
 {
     ren      = GetComponent <SpriteRenderer>();
     animator = GetComponent <Animator>();
     state    = GetComponent <Player_State>();
     timers   = GetComponent <Player_Timers>();
     manager  = GetComponent <PlayerManager>();
 }
Exemplo n.º 9
0
    //Duck logic here
    void Duck()
    {
        playerState = Player_State.EPS_Ducking;

        //Change player Sprites here
        anims[1].SetActive(true);
        anims[0].SetActive(false);
    }
Exemplo n.º 10
0
 // Use this for initialization
 private void Awake()
 {
     animator     = this.GetComponent <Animator>();
     speed        = animator.GetFloat("Speed");
     attack       = animator.GetBool("Attack");
     attack_level = animator.GetInteger("Attack_Level");
     player_state = this.GetComponent <Player_State>();
 }
Exemplo n.º 11
0
 void Start()
 {
     Player     = gameObject.transform.parent.gameObject;
     state      = Player.GetComponent <Player_State>();
     timers     = Player.GetComponent <Player_Timers>();
     attributes = state.attributes;
     collisions = Player.GetComponent <Player_Collisions>();
     attacking  = false;
 }
 void Start()
 {
     lastGroundedPos    = transform.position;
     facingRight        = true;
     doJump             = false;
     player_state       = Player_State.GROUNDED;
     player_rigidbody2D = GetComponent <Rigidbody2D>();
     fgravity_scale     = player_rigidbody2D.gravityScale;
 }
Exemplo n.º 13
0
    public IEnumerator EnemyDead()
    {
        if (mov.health <= 0)
        {
            mov.pos      = true;
            CurrentState = Player_State.GAMEOVER;
        }

        yield return(new WaitForSeconds(6f));
    }
Exemplo n.º 14
0
 void Start()
 {
     state          = GetComponent <Player_State>();
     animator       = GetComponent <Player_Animator>();
     timers         = GetComponent <Player_Timers>();
     attributes     = state.attributes;
     knockbackSpeed = attributes.knockbackSpeed;
     stunTime       = attributes.stunTime;
     immuneTime     = attributes.immuneTime;
 }
Exemplo n.º 15
0
 //Reset the player's position to the origin
 public void ResetPosition()
 {
     playerState = Player_State.EPS_Standing;
     throwParticle.Stop();
     //Change player Sprites here - Make sure they are standing
     anims[1].SetActive(false);
     anims[0].SetActive(true);
     //Change character height back to normal
     transform.position = startPos;
 }
Exemplo n.º 16
0
 // Start is called before the first frame update
 void Start()
 {
     pc            = GameObject.Find("Player");
     speedManager  = pc.GetComponent <Speed_Manager>();
     state         = pc.GetComponent <Player_State>();
     animator      = pc.GetComponent <Player_Animator>();
     timers        = pc.GetComponent <Player_Timers>();
     playerManager = pc.GetComponent <PlayerManager>();
     attributes    = state.attributes;
 }
Exemplo n.º 17
0
 void Start()
 {
     state              = GetComponent <Player_State>();
     animator           = GetComponent <Player_Animator>();
     attributes         = state.attributes;
     moveSpeed          = attributes.moveSpeed;
     pivotTime          = attributes.pivotTime;
     maxDescendAngle    = attributes.maxDescendAngle;
     momentumFactor     = attributes.momentumFactor;
     slopeCollisionMask = attributes.slopeCollisionMask;
 }
Exemplo n.º 18
0
 void Start()
 {
     state          = GetComponent <Player_State>();
     animator       = GetComponent <Player_Animator>();
     timers         = GetComponent <Player_Timers>();
     attributes     = state.attributes;
     leftWallCheck  = gameObject.transform.GetChild(2).gameObject.GetComponent <WallCheck>();
     rightWallCheck = gameObject.transform.GetChild(3).gameObject.GetComponent <WallCheck>();
     ReceiveValues();
     attackTime = attributes.attackTime;
 }
Exemplo n.º 19
0
 public void ChScript(Player_State newState)
 {
     if (_isinit)
     {
         _states[currentState].enabled = false;
         _states[currentState].EndState();
     }
     currentState = newState;
     _states[currentState].BeginState();
     _states[currentState].enabled = true;
 }
Exemplo n.º 20
0
 public Player_State_List(int userCount)
 {
     this.userCount   = userCount;
     this.isConnected = new int[userCount];
     this.states      = new Player_State[userCount];
     for (int i = 0; i < userCount; i++)
     {
         states[i] = new Player_State(i);
     }
     jsonDATA = new string[userCount];
 }
Exemplo n.º 21
0
 public void JsonToState()
 {
     states = new Player_State[userCount];
     for (int i = 0; i < userCount; i++)
     {
         states[i] = new Player_State(i);
         if (isConnected[i] == 2 && jsonDATA[i] != "")
         {
             states[i] = Converter.JsonToOject <Player_State>(jsonDATA[i]);
         }
     }
 }
Exemplo n.º 22
0
 // Use this for initialization
 void Start()
 {
     mainCameraT    = Camera.main.gameObject.transform;
     CameraD_object = new GameObject();
     CameraD_object.transform.parent        = transform;
     CameraD_object.transform.localPosition = transform.position;
     CameraD_object.name = "Direction";
     CameraD             = CameraD_object.transform;
     _playerState        = transform.GetComponent <Player_State>();
     _audiosource        = GetComponent <AudioSource>();
     StartCoroutine(FootSound());
 }
Exemplo n.º 23
0
    //Called when the player wants to jump
    void Jump()
    {
        print("jump");
        print(playerState);
        playerState = Player_State.EPS_Jumping;

        //Change player Sprites here
        anims[1].SetActive(false);
        anims[0].SetActive(true);

        rb.AddForce(new Vector2(0, jumpingForce * Mathf.Clamp(dodgeTime, 1, 1.2f)));
    }
Exemplo n.º 24
0
    //global variables

    void Awake()
    {
        //first, reference all of the state scripts
        idleState  = GetComponent <Idle_State> ();
        moveState  = GetComponent <Move_State> ();
        deadState  = GetComponent <Dead_State> ();
        emptyState = GetComponent <Empty_State> ();

        //get prepping
        currentState = Player_State.Idle_State;

        //ready to go
        ChangeState();
    }
Exemplo n.º 25
0
 void Start()
 {
     state       = GetComponent <Player_State>();
     animator    = GetComponent <Player_Animator>();
     timers      = GetComponent <Player_Timers>();
     attributes  = state.attributes;
     groundCheck = gameObject.transform.GetChild(1).gameObject.GetComponent <GroundCheck>();
     ReceiveValues();
     moveSpeed         = attributes.moveSpeed;
     jumpVelocity      = attributes.jumpVelocity;
     diveSpeed         = attributes.diveSpeed;
     landingTime       = attributes.landingTime;
     diveAttackTime    = attributes.diveAttackTime;
     diveCollisionMask = attributes.diveCollisionMask;
 }
Exemplo n.º 26
0
 void Awake()
 {
     // Cache the transform.
     _transform = gameObject.transform;
     // Create the Player State.
     playerState = new Player_State();
     // Set the Default Player States.
     playerState.Default();
     // Assign the Animator Component
     playerState.PlayerAnimation = GetComponent <Animator>();
     _playerAnimator             = playerState.PlayerAnimation;
     // Check for singleton.
     Singleton();
     // Don't destroy this GameObject on scene change.
     DontDestroyOnLoad(gameObject);
 }
Exemplo n.º 27
0
    void OnCollisionEnter(Collision coll)
    {
        if (coll.collider.transform.gameObject.tag == this.gameObject.tag && sphere.owner == this.gameObject)
        {
//			this.state = Player_State.CONTROLLING;
        }


        if (coll.collider.transform.gameObject.tag == "Ball" && !gameObject.GetComponent <Player>().temporallyUnselectable)
        {
            if (inGame.state == InGameState.GameState.PLAYING)
            {
                inGame.lastTouched = gameObject;
            }

            Vector3 relativePos = transform.InverseTransformPoint(sphere.gameObject.transform.position);

            // detects if player is getting ball
            if (relativePos.y < 2.20f && relativePos.y > -2.0f && relativePos.z > -1.0f)
            {
                GameObject ball = coll.collider.transform.gameObject;
                ball.GetComponent <Sphere>().owner = gameObject;
                coll.rigidbody.rotation            = Quaternion.identity;

                if (gameObject.tag == "OponentTeam")
                {
                    state = Player.Player_State.OPONENT_ATTACK;
                }
                else if (gameObject.tag == "PlayerTeam")
                {
                    state = Player.Player_State.CONTROLLING;
                }
            }
        }



        if (coll.collider.transform.gameObject.tag == "PlayerTeam" || coll.collider.transform.gameObject.tag == "OponentTeam")
        {
            ContactPoint cp           = coll.contacts[0];
            Vector3      normalTipped = new Vector3(cp.normal.x, 0.0f, cp.normal.z);
            Vector3      temp         = new Vector3(transform.position.x + capsuleCollider.center.x, cp.point.y, transform.position.z + capsuleCollider.center.z);
            float        distFromCenterToPointContact = (cp.point - temp).magnitude;
            transform.position += normalTipped * (radiusCapsule - distFromCenterToPointContact + 0.05f);
        }
    }
Exemplo n.º 28
0
    public IEnumerator EnemyIdle(bool tick)
    {
        while (currentState == Player_State.IDLE)
        {
            while (tick)
            {
                if (mov.run)
                {
                    Debug.Log("in loop");
                    tick         = false;
                    CurrentState = Player_State.RUNNING;
                }
            }

            yield return(null);
        }
    }
Exemplo n.º 29
0
 // Start is called before the first frame update
 void Start()
 {
     player       = GameObject.Find("Player");
     speedManager = player.GetComponent <Speed_Manager>();
     state        = player.GetComponent <Player_State>();
     animator     = player.GetComponent <Player_Animator>();
     timers       = player.GetComponent <Player_Timers>();
     attributes   = state.attributes;
     deathTime    = attributes.deathTime;
     if (instance == null)
     {
         instance = this;
     }
     else
     {
         Destroy(this.gameObject);
     }
 }
Exemplo n.º 30
0
 void Start()
 {
     state             = GetComponent <Player_State>();
     animator          = GetComponent <Player_Animator>();
     timers            = GetComponent <Player_Timers>();
     attributes        = state.attributes;
     jumpCount         = state.jumpCount;
     onGround          = state.onGround;
     onQuicksand       = state.onQuicksand;
     onWall            = state.onWall;
     airborne          = state.airborne;
     control           = state.control;
     wantToJump        = state.wantToJump;
     jumping           = state.jumping;
     doubleJumping     = state.doubleJumping;
     displacementTimer = timers.displacementTimer;
     jumpBufferTimer   = timers.jumpBufferTimer;
     jumpTimer         = timers.jumpTimer;
     jumpBufferTime    = attributes.jumpBufferTime;
     jumpTime          = attributes.jumpTime;
 }