Esempio n. 1
0
    public void changestate()
    {
        switch (state)
        {
        case (player_state.begin):
            if (control.after_move == false)
            {
                if (a == 0)
                {
                    state = player_state.nothing;
                }
                else if (a == 1)
                {
                    state = player_state.move;
                }
                else if (a == 2)
                {
                    state = player_state.attack;
                }
            }
            if (control.after_move == true)
            {
                if (a == 0)
                {
                    state = player_state.nothing;
                }
                else if (a == 2)
                {
                    state = player_state.attack;
                }
            }
            break;

        case (player_state.move):
            control.for_move = true;
            control.addforce_all(peoples[0]);
            break;

        case (player_state.attack):
            control.for_atttack = true;
            attack(0, peoples[0]);
            break;

        case (player_state.nothing):
            Debug.Log("here");
            float x = Random.value;
            if (x > 0.5)
            {
                controller.State = Game_controller.Game_State.Game_Enemy;
            }
            else
            {
                controller.State = Game_controller.Game_State.Game_Supply;
            }
            control.can_attack = true;
            state = player_state.begin;
            control.after_move = false;
            break;
        }
    }
Esempio n. 2
0
    // Use this for initialization
    void Start()
    {
        rBody = GetComponent <Rigidbody2D>();

        //get reference to the animator located on the beaver_sprite child object
        beaverSprite = transform.GetChild(1).gameObject;
        animator     = beaverSprite.GetComponent <Animator>();

        //reference to the beaver mouth (to determine if can breath)
        beaverMouth = beaverSprite.transform.GetChild(1).gameObject;

        moveInputScript   = gameObject.GetComponent <get_input>();
        playerStateScript = gameObject.GetComponent <player_state>();

        facingAngle = 0.0f;

        facingRight = true; //facing right initially

        leftAnalogThresh = 0.001f;

        moveForce = constants.moveForceNormal;

        animator.SetBool("on_land", true);
        animator.SetBool("is_moving", false);

        soundPlayer = GameObject.FindGameObjectWithTag("Sound_Player").GetComponent <sound_player>();

        //team 2 faces left to start
        if (playerStateScript.GetTeamNumber() == "2")
        {
            Flip();
        }
    }
    void OnCollisionEnter2D(Collision2D col)
    {
        if (!playerStateScript.GetIsSuffocating())
        {
            //figure out what player/team this instance is, and check if it's colliding with the enemy team players
            if (col.gameObject.tag == "Player")
            {
                enemyPlayer = col.gameObject;                 //current player is beaverSprite

                // enemyInputScript = enemyPlayer.GetComponent<get_input>();
                enemyStateScript = enemyPlayer.GetComponent <player_state> ();

                //only want players of opposite teams
                if (playerStateScript.GetTeamNumber() != enemyStateScript.GetTeamNumber())
                {
                    //TODO: case for both have dash on
                    if (enemyStateScript.GetIsDashing() == true)                        //enemy has dash on
                    //player becomes immobile and drops the pearl in the direction of impact
                    {
                        damageScript.Damage();

                        //knockback the other player (This player)
                        //StartCoroutine(Knockback(beaverSprite, 1f, 350, beaverSprite.transform.position));
                    }
                }
            }
        }
    }
Esempio n. 4
0
    // Use this for initialization
    void Start()
    {
        beaverIcon = GetComponent <SpriteRenderer> ();
        iconAnim   = GetComponent <Animator>();

        if (gameObject.name == "breath_indicator1")
        {
            playerStateScript = GameObject.Find("Beaver1").GetComponent <player_state> ();
            player            = GameObject.Find("Beaver1").gameObject;
            breatheIn         = "i";
            breatheOut        = "o";
        }
        else
        {
            playerStateScript = GameObject.Find("Beaver2").GetComponent <player_state> ();
            player            = GameObject.Find("Beaver2").gameObject;
            breatheIn         = "k";
            breatheOut        = "l";
        }

        if (!constants.hasTech)
        {
            beaverIcon.enabled = false;
            transform.GetChild(0).GetComponent <SpriteRenderer>().enabled = false;
        }
    }
    void OnCollisionEnter2D(Collision2D col)
    {
        if (!playerStateScript.GetIsSuffocating ()) {
            //figure out what player/team this instance is, and check if it's colliding with the enemy team players
            if (col.gameObject.tag == "Player") {
                enemyPlayer = col.gameObject; //current player is beaverSprite

                // enemyInputScript = enemyPlayer.GetComponent<get_input>();
                enemyStateScript = enemyPlayer.GetComponent<player_state> ();

                //only want players of opposite teams
                if (playerStateScript.GetTeamNumber () != enemyStateScript.GetTeamNumber ()) {
                    //TODO: case for both have dash on
                    if (enemyStateScript.GetIsDashing () == true) { //enemy has dash on
                        //player becomes immobile and drops the pearl in the direction of impact
                        damageScript.Damage ();

                        //knockback the other player (This player)
                        //StartCoroutine(Knockback(beaverSprite, 1f, 350, beaverSprite.transform.position));
                    }

                }

            }

        }
    }
    private string startButton; // start or pause button

    // Use this for initialization
    void Start()
    {
        //grab reference to state script
        playerStateScript = GetComponent <player_state> ();

        // check the os to ensure that the proper control scheme is used
        RuntimePlatform os = Application.platform;

        print(os.ToString());
        if (os == RuntimePlatform.WindowsEditor || os == RuntimePlatform.WindowsPlayer)
        {
            isPC = true;
            print("it's windows!!");
        }
        else if (os == RuntimePlatform.OSXEditor || os == RuntimePlatform.OSXPlayer)
        {
            isPC = false;
            print("it's Mac!!");
        }
        else
        {
            isPC = true;
            print("it's Other!!");
        }

        //SetPlayerID (playerID);
        SetPlayerID(playerStateScript.GetPlayerID());
    }
Esempio n. 7
0
 void Start()
 {
     controller = GameObject.FindGameObjectWithTag("GameController").GetComponent <Game_controller>();
     people     = GameObject.FindGameObjectWithTag("GameController").GetComponent <People>();
     weapons    = GameObject.FindGameObjectWithTag("GameController").GetComponent <Weapon>();
     control    = GameObject.FindGameObjectWithTag("GameController").GetComponent <Control>();
     peoples    = people.GetPeople();
     state      = player_state.begin;
 }
Esempio n. 8
0
    void OnTriggerEnter2D(Collider2D other)
    {
        if (other.tag == "Pearl")
        {
            Destroy(other.gameObject);


            if (gameObject.tag == "Left_Clam")
            {
                scoreKeeperScript.IncrementLeftScore();

                clamSprite.material.color = leftScoredColor;
            }
            else if (gameObject.tag == "Right_Clam")
            {
                scoreKeeperScript.IncrementRightScore();

                clamSprite.material.color = rightScoredColor;
            }

            animator.SetTrigger("scored");

            //Wait a little bit before spawning a new pearl
            Invoke("CreateNewPearl", 1.5f);
        }
        else if (other.tag == "Player")
        {
            player_state        playerStateScript     = other.gameObject.GetComponentInParent <player_state>();
            collision_detection playerCollisionScript = other.gameObject.GetComponentInParent <collision_detection>();

            if (playerStateScript.GetHasPearl())
            {
                playerCollisionScript.HidePearl();

                playerStateScript.SetHasPearl(false);

                if (gameObject.tag == "Left_Clam")
                {
                    scoreKeeperScript.IncrementLeftScore();

                    clamSprite.material.color = leftScoredColor;
                }
                else if (gameObject.tag == "Right_Clam")
                {
                    scoreKeeperScript.IncrementRightScore();

                    clamSprite.material.color = rightScoredColor;
                }

                animator.SetTrigger("scored");

                //Wait a little bit before spawning a new pearl
                Invoke("CreateNewPearl", 1.5f);
            }
        }
    }
Esempio n. 9
0
    // Use this for initialization
    void Start()
    {
        //dashInputScript = GetComponent<get_input>();
        playerStateScript = GetComponent <player_state>();
        movingScript      = GetComponent <moving>();
        throwingScript    = GetComponent <throwing>();

        animator = transform.GetChild(1).gameObject.GetComponent <Animator> ();

        soundPlayer = GameObject.FindGameObjectWithTag("Sound_Player").GetComponent <sound_player>();
    }
Esempio n. 10
0
    // Use this for initialization
    void Start()
    {
        //dashInputScript = GetComponent<get_input>();
        playerStateScript = GetComponent<player_state>();
        movingScript = GetComponent<moving>();
        throwingScript = GetComponent<throwing>();

        animator = transform.GetChild(1).gameObject.GetComponent<Animator> ();

        soundPlayer = GameObject.FindGameObjectWithTag ("Sound_Player").GetComponent<sound_player>();
    }
Esempio n. 11
0
    // Use this for initialization
    void Start()
    {
        inputScript = gameObject.GetComponent<get_input>();
        playerStateScript = gameObject.GetComponent<player_state>();
        movingScript = gameObject.GetComponent<moving>();
        pearlOffset = transform.GetChild(0).gameObject;

        pearlRenderer = pearlOffset.GetComponent<SpriteRenderer>();
        anim = pearlOffset.GetComponent<Animator> ();

        throwAngle = 0.0f;
        aimingThreshold = 0.001f; // if this value is too high the aiming tends to snap to the NSEW directions (0.2 was too high)
    }
Esempio n. 12
0
    // Use this for initialization
    void Start()
    {
        inputScript       = gameObject.GetComponent <get_input>();
        playerStateScript = gameObject.GetComponent <player_state>();
        movingScript      = gameObject.GetComponent <moving>();
        pearlOffset       = transform.GetChild(0).gameObject;

        pearlRenderer = pearlOffset.GetComponent <SpriteRenderer>();
        anim          = pearlOffset.GetComponent <Animator> ();

        throwAngle      = 0.0f;
        aimingThreshold = 0.001f;         // if this value is too high the aiming tends to snap to the NSEW directions (0.2 was too high)
    }
Esempio n. 13
0
    void Start()
    {
        //get the state script
        playerStateScript = GetComponent <player_state> ();

        //get the
        GameObject beaverSprite = transform.GetChild(1).gameObject;

        beaverMouth = transform.GetChild(1).gameObject;

        beaverPearlCollider = beaverSprite.transform.GetChild(0).gameObject;

        // get Player name form patent object
        Player_name = gameObject.transform.name;


        //gettign the scripts that will be disabled
        movingScript    = GetComponent <moving> ();
        dashScript      = GetComponent <dash> ();
        throwingScript  = GetComponent <throwing> ();
        colDetectScript = GetComponent <collision_detection> ();

        //get the scripts to animate the indicator

//		if (Player_name == "Beaver1") {
//			iconIndicator = GameObject.FindGameObjectWithTag ("iconP1").GetComponent<Animator>();
//
//		} else if (Player_name == "Beaver2") {
//			iconIndicator = GameObject.FindGameObjectWithTag ("iconP2").GetComponent<Animator>();
//		}

        //getting the particle system
        Bubbles = beaverMouth.GetComponentInChildren <ParticleSystem> ();

        //setting the emmision to 0
        Bubbles.emissionRate = 0;

        //initially not suffocating
        //isSuffocating = false;
        playerStateScript.SetIsSuffocating(false);

        // gettign the ridgit body of the Player
        rBody = GetComponent <Rigidbody2D> ();


        // getting the animator.
        animator = transform.GetChild(1).gameObject.GetComponent <Animator> ();

        soundPlayer = GameObject.FindGameObjectWithTag("Sound_Player").GetComponent <sound_player>();
    }
Esempio n. 14
0
    void Start()
    {
        allowMovement  = true;
        spriteRenderer = transform.GetComponentInChildren <SpriteRenderer>();
        plAnimation    = transform.GetComponentInChildren <Animator>();

        glitchParticles = transform.FindChild("GlitchParticles").GetComponent <ParticleSystem>();
        jumpParticles   = transform.FindChild("JumpParticles").GetComponent <ParticleSystem>();
        dustParticles   = transform.FindChild("DustParticles").GetComponent <ParticleSystem>();

        teleport = transform.FindChild("Powers/Teleport").GetComponent <TeleportScript>();
        slowFPS  = transform.FindChild("Powers/SlowFPS").GetComponent <SlowFPS>();

        state = player_state.IN_GROUND;
    }
Esempio n. 15
0
    void Start()
    {
        r_body = GetComponent <Rigidbody2D>();

        dashInputScript   = GetComponent <get_input>();
        playerStateScript = GetComponent <player_state>();
        movingScript      = GetComponent <moving>();
        // throwingScript = GetComponent<throwing>();

        soundPlayer = GameObject.FindGameObjectWithTag("Sound_Player").GetComponent <sound_player>();

        //get reference to the animator located on the beaver_sprite child object
        beaverSprite = transform.GetChild(1).gameObject;
        animator     = beaverSprite.GetComponent <Animator>();
    }
Esempio n. 16
0
    void Start()
    {
        //get references to the child object
        pearlOffset  = transform.GetChild(0).gameObject;
        beaverSprite = transform.GetChild(1).gameObject;

        //get reference to the sprite renderer located on the pearlOffset child object
        pearlRenderer = pearlOffset.GetComponent <SpriteRenderer>();

        throwInputScript  = gameObject.GetComponent <get_input>();
        aimingDirScript   = gameObject.GetComponent <aiming>();
        colDetectScript   = transform.GetComponent <collision_detection> ();
        playerStateScript = GetComponent <player_state>();

        soundPlayer = GameObject.FindGameObjectWithTag("Sound_Player").GetComponent <sound_player>();
    }
Esempio n. 17
0
    public void GetSticked(Vector3 directionStick)
    {
        state = player_state.STICKED;
        timeSinceChangeMoving = 0.0f;
        rigidBody.useGravity  = false;
        rigidBody.velocity    = new Vector3(0, 0, 0);
        if (InputManager.ActiveDevice.Action1.IsPressed)
        {
            playerJumpingInSticked = true;
        }
        else
        {
            playerJumpingInSticked = false;
        }

        directionStickObject = directionStick;
    }
Esempio n. 18
0
 public bool ActivatingTeleport()
 {
     if (InputManager.ActiveDevice.Action3.IsPressed && allowMovement && !teleport.teleportUsed && teleport.CheckTeleport(boxCollider))
     {
         state = player_state.TELEPORTING;
         rigidBody.useGravity = false;
         plAnimation.SetTrigger("Teleport");
         plAnimation.speed          = 1.0f / teleport.getDuration();
         rigidBody.detectCollisions = false;
         DoGlitchParticles();
         glitchOffsetCamera.divisions    = 50;
         glitchOffsetCamera.inestability = 1.0f;
         glitchOffsetCamera.frequency    = 1.0f;
         glitchOffsetCamera.enabled      = true;
         return(true);
     }
     return(false);
 }
    // Use this for initialization
    void Start()
    {
        //get references to the child objects
        pearlOffset = transform.GetChild(0).gameObject;

        //get reference to the sprite renderer located on the pearlOffset child object
        pearlRenderer = pearlOffset.GetComponent <SpriteRenderer>();

        playerStateScript = gameObject.GetComponent <player_state>();

        numberOfPlatformsTouching = 0;

        damageScript = GetComponent <damage> ();

        rBody = GetComponent <Rigidbody2D> ();

        scoreScript = GameObject.FindGameObjectWithTag("Score_Keeper").GetComponent <score_keeper>();

        statusAnim = GetComponent <Animator> ();

        soundPlayer = GameObject.FindGameObjectWithTag("Sound_Player").GetComponent <sound_player>();
    }
    // Use this for initialization
    void Start()
    {
        beaverIcon = GetComponent<SpriteRenderer> ();
        iconAnim = GetComponent<Animator>();

        if (gameObject.name == "breath_indicator1") {
            playerStateScript = GameObject.Find ("Beaver1").GetComponent<player_state> ();
            player = GameObject.Find ("Beaver1").gameObject;
            breatheIn = "i";
            breatheOut= "o";
        } else {
            playerStateScript = GameObject.Find ("Beaver2").GetComponent<player_state> ();
            player = GameObject.Find ("Beaver2").gameObject;
            breatheIn = "k";
            breatheOut= "l";
        }

        if (!constants.hasTech) {
            beaverIcon.enabled = false;
            transform.GetChild(0).GetComponent<SpriteRenderer>().enabled = false;
        }
    }
Esempio n. 21
0
    void Start()
    {
        allowMovement = true;
        spriteRenderer = transform.GetComponentInChildren<SpriteRenderer>();
        plAnimation = transform.GetComponentInChildren<Animator>();

        glitchParticles = transform.FindChild("GlitchParticles").GetComponent<ParticleSystem>();
        jumpParticles = transform.FindChild("JumpParticles").GetComponent<ParticleSystem>();
        dustParticles = transform.FindChild("DustParticles").GetComponent<ParticleSystem>();

        teleport = transform.FindChild("Powers/Teleport").GetComponent<TeleportScript>();
        slowFPS = transform.FindChild("Powers/SlowFPS").GetComponent<SlowFPS>();

        state = player_state.IN_GROUND;
    }
Esempio n. 22
0
    // Use this for initialization
    void Start()
    {
        //grab reference to state script
        playerStateScript = GetComponent<player_state> ();

        // check the os to ensure that the proper control scheme is used
        RuntimePlatform os = Application.platform;
        print(os.ToString());
        if (os == RuntimePlatform.WindowsEditor || os == RuntimePlatform.WindowsPlayer)
        {
            isPC = true;
            print("it's windows!!");
        }
        else if (os == RuntimePlatform.OSXEditor || os == RuntimePlatform.OSXPlayer)
        {
            isPC = false;
            print("it's Mac!!");
        }
        else
        {
            isPC = true;
            print("it's Other!!");
        }

        //SetPlayerID (playerID);
        SetPlayerID (playerStateScript.GetPlayerID ());
    }
Esempio n. 23
0
    // Use this for initialization
    void Start()
    {
        rBody = GetComponent<Rigidbody2D>();

        //get reference to the animator located on the beaver_sprite child object
        beaverSprite = transform.GetChild(1).gameObject;
        animator = beaverSprite.GetComponent<Animator>();

        //reference to the beaver mouth (to determine if can breath)
        beaverMouth = beaverSprite.transform.GetChild (1).gameObject;

        moveInputScript = gameObject.GetComponent<get_input>();
        playerStateScript = gameObject.GetComponent<player_state>();

        facingAngle = 0.0f;

        facingRight = true; //facing right initially

        leftAnalogThresh = 0.001f;

        moveForce = constants.moveForceNormal;

        animator.SetBool ("on_land", true);
        animator.SetBool ("is_moving", false);

        soundPlayer = GameObject.FindGameObjectWithTag ("Sound_Player").GetComponent<sound_player>();

        //team 2 faces left to start
        if (playerStateScript.GetTeamNumber () == "2") {
            Flip ();
        }
    }
Esempio n. 24
0
    void FixedUpdate()
    {
		previouslySticked = false;

        // State-changing calculations
        switch (state)
        {
            case player_state.PREPARING_JUMP:

                SoundManager.instance.PlaySingle(jumpSound);

                timePreparingJump += Time.deltaTime;
                rigidBody.AddForce(new Vector3(0.0f, jumpForce, 0.0f));
                //If it's ready to jump, start jump and give fall recovery time
                state = player_state.JUMPING;
                plAnimation.SetBool("Jump", true);
                plAnimation.SetBool("Run", false);
                jumpParticles.Play();
    
                Movement();
                break;

		    case player_state.FALL_RECOVERING:


				state = player_state.IN_GROUND;

				plAnimation.SetBool ("Run", false);
				plAnimation.SetBool ("Jump", false);
				plAnimation.SetBool ("Falling", false);
	

                // To control movement of player
                Movement();

                break;


			case player_state.IN_GROUND:

                // If it's not teleporting
                if (!ActivatingTeleport())
                {
                    teleport.teleportUsed = false;

                    if (transform.parent != null)
                    {
                        transform.rotation = transform.parent.rotation;
                    }

                    //If the jump key is being pressed but it has been released since the
                    //last jump
					if (InputManager.ActiveDevice.Action1.IsPressed && allowMovement && !playerActivedJump)
                    {
                        timePreparingJump = 0.0f;
                        playerActivedJump = true;
                        state = player_state.PREPARING_JUMP;
                        rigidBody.useGravity = false;
                    }
                    else if (!IsGrounded())
                    {
                        state = player_state.JUMPING;
                        plAnimation.SetBool("Falling", true);
                        plAnimation.SetBool("Run", false);
                    }


                    // To control movement of player
                    Movement();

                }
                break;

            case player_state.JUMPING:

				//Change animation to falling
                if (rigidBody.velocity.y < 0 && plAnimation.GetBool("Falling") == false)
                {
                    plAnimation.SetBool("Jump", false);
                    plAnimation.SetBool("Falling", true);
                }

                // If it's not teleporting
                if (!ActivatingTeleport())
                {
                    //If it's grounded
                    if (IsGrounded())
                    {
                        //Start fall recovering and set the bools
                        state = player_state.FALL_RECOVERING;
                        plAnimation.SetBool("Falling", false);
                        if (plAnimation.GetBool("Jump") == true)
                        {
                            plAnimation.SetBool("Jump", false);
                        }
                    }
                    else
                    {

                        timePreparingJump += Time.fixedDeltaTime;

                        if(!playerActivedJump || (timePreparingJump > maxJumpTime))
                        {
                            rigidBody.useGravity = true;
                        }

                        //Angle correction
                        Vector3 eulerAngles = gameObject.transform.rotation.eulerAngles;
                        float rotationZ = 0.0f;

                        if (eulerAngles.z < 0.0f)
                        {
                            eulerAngles.z += 360.0f;
                        }

                        if (eulerAngles.z != 0.0f)
                        {
                            if (eulerAngles.z <= 3.0f || eulerAngles.z >= 357.0f)
                            {
                                rotationZ = 0.0f;
                            }
                            else if (eulerAngles.z <= 180.0f)
                            {
                                rotationZ = eulerAngles.z - 3.0f;
                            }
                            else if (eulerAngles.z > 180.0f)
                            {
                                rotationZ = eulerAngles.z + 3.0f;
                            }
                            gameObject.transform.rotation = Quaternion.Euler(eulerAngles.x, eulerAngles.y, rotationZ);
                        }
						//END Angle correction
                    }
                    // To control movement of player
                    Movement();
                }
                break;

            case player_state.TELEPORTING:

                Vector3 position;
                bool ended = teleport.movePosition(out position);
                rigidBody.MovePosition(position);

                if (ended)
                {
                    state = player_state.JUMPING;
                    plAnimation.speed = 1;
                    rigidBody.detectCollisions = true;
                    rigidBody.useGravity = true;
                    rigidBody.velocity = new Vector3(rigidBody.velocity.x, 0.0f, 0.0f);
                    if (!slowFPS.powerActive)
                    {
                        glitchOffsetCamera.enabled = false;
                    }
                    else
                    {
                        glitchOffsetCamera.divisions = 20;
                        glitchOffsetCamera.inestability = 0.3f;
                        glitchOffsetCamera.frequency = 0.5f;
                    }
                }

                break;

            case player_state.DEATH:
                rigidBody.velocity = Vector3.zero;

                if (walkSource != null && walkSource.isPlaying)
                    walkSource.Stop();

                break;

			case player_state.STICKED:
				previouslySticked = true;
                timeSinceChangeMoving += Time.deltaTime;

                if (InputManager.ActiveDevice.Action1.IsPressed && !playerJumpingInSticked) {

                    playerJumpingInSticked = true;

                    rigidBody.useGravity = true;
					rigidBody.AddForce(new Vector3(0.0f, stickedJumpForce, 0.0f));
					rigidBody.velocity = new Vector3 (4f, -directionStickObject.x * rigidBody.velocity.y, 0.0f);
					
					velocityWhenChangedState = -directionStickObject.x * 20f;
					timeToChangeDependingVelocity = 1f;
					timeSinceChangeMoving = 0.0f;
					playerMovingType = moving_type.STOPING;

					state = player_state.JUMPING;
				}
                else if(timeSinceChangeMoving > maxTimeSticked)
                {
                    rigidBody.useGravity = true;
                    playerJumpingInSticked = false;

                    velocityWhenChangedState = 0f;
                    timeToChangeDependingVelocity = 1f;
                    timeSinceChangeMoving = 0.0f;
                    playerMovingType = moving_type.STOPING;

                    state = player_state.JUMPING;
                }
                else if(playerJumpingInSticked && !InputManager.ActiveDevice.Action1.IsPressed)
                {
                    playerJumpingInSticked = false;
                }
                break;
        }

        //If a player-induced jump is checked but the jump key is not longer
        //being held, set it to false so it can jump again
		if (playerActivedJump && !InputManager.ActiveDevice.Action1.IsPressed && allowMovement){
            playerActivedJump = false;
		}

    }
    void Start()
    {
        //get the state script
        playerStateScript = GetComponent<player_state> ();

        //get the
        GameObject beaverSprite = transform.GetChild (1).gameObject;
        beaverMouth = transform.GetChild (1).gameObject;

        beaverPearlCollider = beaverSprite.transform.GetChild (0).gameObject;

        // get Player name form patent object
        Player_name = gameObject.transform.name;

        //gettign the scripts that will be disabled
        movingScript = GetComponent<moving> ();
        dashScript = GetComponent<dash> ();
        throwingScript = GetComponent<throwing> ();
        colDetectScript = GetComponent<collision_detection> ();

        //get the scripts to animate the indicator

        //		if (Player_name == "Beaver1") {
        //			iconIndicator = GameObject.FindGameObjectWithTag ("iconP1").GetComponent<Animator>();
        //
        //		} else if (Player_name == "Beaver2") {
        //			iconIndicator = GameObject.FindGameObjectWithTag ("iconP2").GetComponent<Animator>();
        //		}

        //getting the particle system
        Bubbles = beaverMouth.GetComponentInChildren<ParticleSystem> ();

        //setting the emmision to 0
        Bubbles.emissionRate = 0;

        //initially not suffocating
        //isSuffocating = false;
        playerStateScript.SetIsSuffocating (false);

        // gettign the ridgit body of the Player
        rBody = GetComponent<Rigidbody2D> ();

        // getting the animator.
        animator = transform.GetChild (1).gameObject.GetComponent<Animator> ();

        soundPlayer = GameObject.FindGameObjectWithTag ("Sound_Player").GetComponent<sound_player>();
    }
Esempio n. 26
0
 public bool ActivatingTeleport()
 {
     if (InputManager.ActiveDevice.Action3.IsPressed && allowMovement && !teleport.teleportUsed && teleport.CheckTeleport(boxCollider))
     {
         state = player_state.TELEPORTING;
         rigidBody.useGravity = false;
         plAnimation.SetTrigger("Teleport");
         plAnimation.speed = 1.0f / teleport.getDuration();
         rigidBody.detectCollisions = false;
         DoGlitchParticles();
         glitchOffsetCamera.divisions = 50;
         glitchOffsetCamera.inestability = 1.0f;
         glitchOffsetCamera.frequency = 1.0f;
         glitchOffsetCamera.enabled = true;
         return true;
     }
     return false;
 }
Esempio n. 27
0
    void Start()
    {
        //get references to the child object
        pearlOffset = transform.GetChild(0).gameObject;
        beaverSprite = transform.GetChild (1).gameObject;

        //get reference to the sprite renderer located on the pearlOffset child object
        pearlRenderer = pearlOffset.GetComponent<SpriteRenderer>();

        throwInputScript = gameObject.GetComponent<get_input>();
        aimingDirScript = gameObject.GetComponent<aiming>();
        colDetectScript = transform.GetComponent<collision_detection> ();
        playerStateScript = GetComponent<player_state>();

        soundPlayer = GameObject.FindGameObjectWithTag ("Sound_Player").GetComponent<sound_player>();
    }
Esempio n. 28
0
	public void GetSticked(Vector3 directionStick){
		state = player_state.STICKED;
        timeSinceChangeMoving = 0.0f;
        rigidBody.useGravity = false;
		rigidBody.velocity = new Vector3(0, 0, 0);
        if (InputManager.ActiveDevice.Action1.IsPressed)
            playerJumpingInSticked = true;
        else
            playerJumpingInSticked = false;

        directionStickObject = directionStick;
	}
Esempio n. 29
0
    // Checker for Icon initializing   ( which Icon should it initialize or swap )
    void initChecker(player_state ps, int i)
    {
        if (ps && panelCtrls [i].GetComponent <Animator> ().GetBool("intro") == false)
        {
            if (i == 3 || i == 6)
            {
                switch (i)
                {
                case 3:
                    swapPanelCtrls(0, 3);
                    termPanel(1);
                    termPanel(2);
                    break;

                case 6:
                    swapPanelCtrls(3, 6);
                    termPanel(4);
                    termPanel(5);
                    break;
                }
            }
            else
            {
                initPanel(i);
            }
        }
        else if (!ps)
        {
            switch (i)
            {
            case 0:
                initPanel(0);
                break;

            case 1:
                initPanel(0);
                initPanel(1);
                break;

            case 2:
                initPanel(0);
                initPanel(1);
                initPanel(2);
                break;

            case 3:
                initPanel(3);
                break;

            case 4:
                initPanel(4);
                initPanel(3);
                break;

            case 5:
                initPanel(5);
                initPanel(4);
                initPanel(3);
                break;

            case 6:
                initPanel(6);
                break;

            case 7:
                initPanel(7);
                initPanel(6);
                break;

            case 8:
                initPanel(8);
                initPanel(7);
                initPanel(6);
                break;
            }
        }
    }
Esempio n. 30
0
    void FixedUpdate()
    {
        previouslySticked = false;

        // State-changing calculations
        switch (state)
        {
        case player_state.PREPARING_JUMP:

            SoundManager.instance.PlaySingle(jumpSound);

            timePreparingJump += Time.deltaTime;
            rigidBody.AddForce(new Vector3(0.0f, jumpForce, 0.0f));
            //If it's ready to jump, start jump and give fall recovery time
            state = player_state.JUMPING;
            plAnimation.SetBool("Jump", true);
            plAnimation.SetBool("Run", false);
            jumpParticles.Play();

            Movement();
            break;

        case player_state.FALL_RECOVERING:


            state = player_state.IN_GROUND;

            plAnimation.SetBool("Run", false);
            plAnimation.SetBool("Jump", false);
            plAnimation.SetBool("Falling", false);


            // To control movement of player
            Movement();

            break;


        case player_state.IN_GROUND:

            // If it's not teleporting
            if (!ActivatingTeleport())
            {
                teleport.teleportUsed = false;

                if (transform.parent != null)
                {
                    transform.rotation = transform.parent.rotation;
                }

                //If the jump key is being pressed but it has been released since the
                //last jump
                if (InputManager.ActiveDevice.Action1.IsPressed && allowMovement && !playerActivedJump)
                {
                    timePreparingJump    = 0.0f;
                    playerActivedJump    = true;
                    state                = player_state.PREPARING_JUMP;
                    rigidBody.useGravity = false;
                }
                else if (!IsGrounded())
                {
                    state = player_state.JUMPING;
                    plAnimation.SetBool("Falling", true);
                    plAnimation.SetBool("Run", false);
                }


                // To control movement of player
                Movement();
            }
            break;

        case player_state.JUMPING:

            //Change animation to falling
            if (rigidBody.velocity.y < 0 && plAnimation.GetBool("Falling") == false)
            {
                plAnimation.SetBool("Jump", false);
                plAnimation.SetBool("Falling", true);
            }

            // If it's not teleporting
            if (!ActivatingTeleport())
            {
                //If it's grounded
                if (IsGrounded())
                {
                    //Start fall recovering and set the bools
                    state = player_state.FALL_RECOVERING;
                    plAnimation.SetBool("Falling", false);
                    if (plAnimation.GetBool("Jump") == true)
                    {
                        plAnimation.SetBool("Jump", false);
                    }
                }
                else
                {
                    timePreparingJump += Time.fixedDeltaTime;

                    if (!playerActivedJump || (timePreparingJump > maxJumpTime))
                    {
                        rigidBody.useGravity = true;
                    }

                    //Angle correction
                    Vector3 eulerAngles = gameObject.transform.rotation.eulerAngles;
                    float   rotationZ   = 0.0f;

                    if (eulerAngles.z < 0.0f)
                    {
                        eulerAngles.z += 360.0f;
                    }

                    if (eulerAngles.z != 0.0f)
                    {
                        if (eulerAngles.z <= 3.0f || eulerAngles.z >= 357.0f)
                        {
                            rotationZ = 0.0f;
                        }
                        else if (eulerAngles.z <= 180.0f)
                        {
                            rotationZ = eulerAngles.z - 3.0f;
                        }
                        else if (eulerAngles.z > 180.0f)
                        {
                            rotationZ = eulerAngles.z + 3.0f;
                        }
                        gameObject.transform.rotation = Quaternion.Euler(eulerAngles.x, eulerAngles.y, rotationZ);
                    }
                    //END Angle correction
                }
                // To control movement of player
                Movement();
            }
            break;

        case player_state.TELEPORTING:

            Vector3 position;
            bool    ended = teleport.movePosition(out position);
            rigidBody.MovePosition(position);

            if (ended)
            {
                state                      = player_state.JUMPING;
                plAnimation.speed          = 1;
                rigidBody.detectCollisions = true;
                rigidBody.useGravity       = true;
                rigidBody.velocity         = new Vector3(rigidBody.velocity.x, 0.0f, 0.0f);
                if (!slowFPS.powerActive)
                {
                    glitchOffsetCamera.enabled = false;
                }
                else
                {
                    glitchOffsetCamera.divisions    = 20;
                    glitchOffsetCamera.inestability = 0.3f;
                    glitchOffsetCamera.frequency    = 0.5f;
                }
            }

            break;

        case player_state.DEATH:
            rigidBody.velocity = Vector3.zero;

            if (walkSource != null && walkSource.isPlaying)
            {
                walkSource.Stop();
            }

            break;

        case player_state.STICKED:
            previouslySticked      = true;
            timeSinceChangeMoving += Time.deltaTime;

            if (InputManager.ActiveDevice.Action1.IsPressed && !playerJumpingInSticked)
            {
                playerJumpingInSticked = true;

                rigidBody.useGravity = true;
                rigidBody.AddForce(new Vector3(0.0f, stickedJumpForce, 0.0f));
                rigidBody.velocity = new Vector3(4f, -directionStickObject.x * rigidBody.velocity.y, 0.0f);

                velocityWhenChangedState      = -directionStickObject.x * 20f;
                timeToChangeDependingVelocity = 1f;
                timeSinceChangeMoving         = 0.0f;
                playerMovingType = moving_type.STOPING;

                state = player_state.JUMPING;
            }
            else if (timeSinceChangeMoving > maxTimeSticked)
            {
                rigidBody.useGravity   = true;
                playerJumpingInSticked = false;

                velocityWhenChangedState      = 0f;
                timeToChangeDependingVelocity = 1f;
                timeSinceChangeMoving         = 0.0f;
                playerMovingType = moving_type.STOPING;

                state = player_state.JUMPING;
            }
            else if (playerJumpingInSticked && !InputManager.ActiveDevice.Action1.IsPressed)
            {
                playerJumpingInSticked = false;
            }
            break;
        }

        //If a player-induced jump is checked but the jump key is not longer
        //being held, set it to false so it can jump again
        if (playerActivedJump && !InputManager.ActiveDevice.Action1.IsPressed && allowMovement)
        {
            playerActivedJump = false;
        }
    }
Esempio n. 31
0
    void Start()
    {
        r_body = GetComponent<Rigidbody2D>();

        dashInputScript = GetComponent<get_input>();
        playerStateScript = GetComponent<player_state>();
        movingScript = GetComponent<moving>();
           // throwingScript = GetComponent<throwing>();

        soundPlayer = GameObject.FindGameObjectWithTag ("Sound_Player").GetComponent<sound_player>();

        //get reference to the animator located on the beaver_sprite child object
        beaverSprite = transform.GetChild(1).gameObject;
        animator = beaverSprite.GetComponent<Animator>();
    }
    // Use this for initialization
    void Start()
    {
        //get references to the child objects
        pearlOffset = transform.GetChild (0).gameObject;

        //get reference to the sprite renderer located on the pearlOffset child object
        pearlRenderer = pearlOffset.GetComponent<SpriteRenderer>();

        playerStateScript = gameObject.GetComponent<player_state>();

        numberOfPlatformsTouching = 0;

        damageScript = GetComponent<damage> ();

        rBody = GetComponent<Rigidbody2D> ();

        scoreScript = GameObject.FindGameObjectWithTag("Score_Keeper").GetComponent<score_keeper>();

        statusAnim = GetComponent<Animator> ();

        soundPlayer = GameObject.FindGameObjectWithTag ("Sound_Player").GetComponent<sound_player>();
    }