Ejemplo n.º 1
0
 private void DropDownAction()
 {
     if (Input.GetKeyDown(KeyCode.Space) && currentState == playerState.hasDoubleJumped && !isGrounded && powerUps["DropDown"])
     {
         currentState = playerState.isFalling;
     }
 }
Ejemplo n.º 2
0
 private void ShowCorrectCam(playerState state) {
     if (state == playerState.InInventory) {
         mainCam.gameObject.SetActive(false);
     } else if(state == playerState.InGame){
         mainCam.gameObject.SetActive(true);
     }
 }
Ejemplo n.º 3
0
    bool IsWalk()
    {
        if (h != 0)
        {
            if (IsPush())
            {
                h      = h * 0.4f;
                _state = playerState.push;
            }
            else
            {
                if (h < 0)
                {
                    sp.flipX = true;
                }
                else
                {
                    sp.flipX = false;
                }

                _state = playerState.walk;
                //PlaySoundClip (moveSound);
            }
            return(true);
        }
        else if (isGameover)
        {
            return(false);
        }
        else
        {
            _state = playerState.idle;
            return(false);
        }
    }
Ejemplo n.º 4
0
    private void BetterJump()
    {
        if (Input.GetKeyDown(KeyCode.Space) && isGrounded && powerUps["Jump"])
        {
            anim_Controller.TriggerJumpAnimation();



            rb.velocity  = Vector3.up * jumpForce;
            currentState = playerState.isJumping;

            jumpTimeCounter = jumpTimer;
        }

        if (Input.GetKey(KeyCode.Space) && currentState == playerState.isJumping)
        {
            if (jumpTimeCounter > 0)
            {
                rb.velocity      = Vector3.up * jumpForce;
                jumpTimeCounter -= Time.deltaTime;
            }
            else
            {
                currentState = playerState.canDoubleJump;
            }
        }
        if (Input.GetKeyUp(KeyCode.Space) && currentState == playerState.isJumping)
        {
            currentState = playerState.canDoubleJump;
        }
    }
Ejemplo n.º 5
0
 public void changeToRun()
 {
     if (player != playerState.Running)
     {
         player = playerState.Running;
     }
 }
Ejemplo n.º 6
0
 public void changeToJump()
 {
     if (player != playerState.Jumping)
     {
         player = playerState.Jumping;
     }
 }
Ejemplo n.º 7
0
 public void changeToWalk()
 {
     if (player != playerState.Walking)
     {
         player = playerState.Walking;
     }
 }
Ejemplo n.º 8
0
 private void Whispering()
 {
     // if you press and HOLD Q..
     if (Input.GetKeyDown(KeyCode.Q))
     {
         // Whisper to birds while holding Q
         myAnimator.SetBool("TalkToBirds", true);
         myAnimator.SetBool("Walking", false);
         crossHair.GetComponent <Crosshair>().crosshairstate = Crosshair.CrosshairState.isactive;
         hotdog.GetComponent <Hotdog>().hotdogState          = Hotdog.pigeonState.imlistening;
         pigeonbox[0].GetComponent <Pigeon>().pigeonstate    = Pigeon.pigeonState.imlistening;
     }
     // If you let go of Q after hitting nothing, -> General Movement
     else if (Input.GetKeyUp(KeyCode.Q) && crossHair.GetComponent <Crosshair>().ivehitsomething == false)
     {
         myAnimator.SetBool("TalkToBirds", false);
         state = Player.playerState.GeneralMovement;
         crossHair.GetComponent <Crosshair>().crosshairstate = Crosshair.CrosshairState.isdisabled;
         hotdog.GetComponent <Hotdog>().hotdogState          = Hotdog.pigeonState.resetpigeon;
         pigeonbox[0].GetComponent <Pigeon>().pigeonstate    = Pigeon.pigeonState.followplayer;
     }
     // If you let go of Q after hitting something -> General Movement
     else if (Input.GetKeyUp(KeyCode.Q) && crossHair.GetComponent <Crosshair>().ivehitsomething == true)
     {
         state = Player.playerState.GeneralMovement;
         myAnimator.SetBool("TalkToBirds", false);
         pigeonbox[0].GetComponent <Pigeon>().pigeonstate = Pigeon.pigeonState.followplayer;
     }
 }
Ejemplo n.º 9
0
        void switchState()
        {
            switch (pState)
            {
            case playerState.idle:
                pState = playerState.walking;
                break;

            case playerState.walking:
                pState = playerState.shooting;
                break;

            case playerState.shooting:
                pState = playerState.jumping;
                break;

            case playerState.jumping:
                pState = playerState.smoking;
                break;

            case playerState.smoking:
                pState = playerState.smokingidle;
                break;

            case playerState.smokingidle:
                pState = playerState.crouchingDown;
                break;

            case playerState.crouchingDown:
                pState = playerState.idle;
                break;
            }
        }
Ejemplo n.º 10
0
    public IEnumerator Rematch()
    {
        //Interpolations
        spinWheelController.AnimateEndUI();
        yield return(new WaitForSeconds(0.2f));

        UIManager.Instance.ShowWindow(GameWindow.GamePlay);

        // Reset match manager
        _matchManager.currentRound = 0;

        // Reset Player Data
        seekTimer = oponentSeekTimer = 0;
        spinWheelController._rematchRequestReceived = false;
        _playerInfo.ResetData();

        if (_playerInfo.isMyTurn)
        {
            _playerState = playerState.WaitingToSpawnPoint;
        }
        else
        {
            _playerState = playerState.WaitingToSeek;
        }

        //Addapt UI
        UIManager.Instance.UpdateGamePlayUI(_playerInfo.isMyTurn);
        UIManager.Instance.AnimateBottomBar();
    }
Ejemplo n.º 11
0
    private void airPhysics(ref Vector3 velocityChange)
    {
        float currVelocityY = body.velocity.y;
        float currVelocityX = body.velocity.x;
        int   h_sign        = System.Math.Sign(horizontal_IP);
        bool  isFastFalling = currVelocityY <= 0 && vertical_IP < -.75;

        velocityChange.x += (h_sign * airBaseAcceleration + airAcceleration * horizontal_IP) * Time.deltaTime; //apply air acceletation

        //gravity
        if (isFastFalling)
        {
            state             = playerState.fastFalling;
            velocityChange.y += fastFallGravity * Time.deltaTime;
        }
        else
        {
            state             = playerState.falling;
            velocityChange.y += gravity * Time.deltaTime;
        }

        //limits
        if (Abs(velocityChange.x + currVelocityX) > airSpeed)
        {
            velocityChange.x = h_sign * airSpeed - currVelocityX;
        }
        if (isFastFalling && (velocityChange.y + currVelocityY < fastFallVelocity))
        {
            velocityChange.y = fastFallVelocity - currVelocityY;
        }
        else if (!isFastFalling && (velocityChange.y + currVelocityY < fallVelocity))
        {
            velocityChange.y = fallVelocity - currVelocityY;
        }
    }
Ejemplo n.º 12
0
 void Start()
 {
     rb2d            = GetComponent <Rigidbody2D>();
     anim            = GetComponent <Animator>();
     currentState    = playerState.idle;
     spawnController = GameObject.Find("GameController").GetComponent <SpawnController>();
 }
Ejemplo n.º 13
0
    // Update is called once per frame
    void Update()
    {
        timer += Time.deltaTime;

        if (attacking && timer >= timeBeweenAttacks)
        {
            if (state == playerState.FINAL_ATTACK)
            {
                attacking = false;
            }
            else if (state == playerState.FIRST_ATTACK)
            {
                attacking = false;
            }
            state = playerState.NOT_ATTACKING;
        }

        if (InputManager.LightAttack() && timer <= timeBeweenAttacks && timer >= timeToCombo && attacking && state == playerState.FIRST_ATTACK)
        {
            timer = 0;
            state = playerState.FINAL_ATTACK;
        }

        if (InputManager.LightAttack() && timer >= timeBeweenAttacks && state == playerState.NOT_ATTACKING)
        {
            Attack();
            state = playerState.FIRST_ATTACK;
        }
    }
Ejemplo n.º 14
0
 void OnMouseDown()
 {
     Debug.Log("OnMouseDown()");
     state            = playerState.runup;
     deltaTimeFly     = DateTime.Now;
     currentTimeRunup = DateTime.Now;
 }
Ejemplo n.º 15
0
 // Update is called once per frame
 void Update()
 {
     if (state == playerState.runup && currentTimeRunup.AddMilliseconds(maxRunupTime) < DateTime.Now)
     {
         startFlight(700f);
     }
     if (tr.localPosition.y <= -3.49f && state != playerState.runup && isFirstFly && deltaTimeFly.AddMilliseconds(deltaSecondsTime) < DateTime.Now)
     {
         state = playerState.normal;
     }
     if (state == playerState.normal)
     {
         if (limitXRight <= tr.localPosition.x)
         {
             direction = -1f;
         }
         //Debug.Log("limitXLeft:"+limitXLeft.ToString()+"|pos:"+tr.localPosition.x.ToString());
         if (limitXLeft >= tr.localPosition.x)
         {
             direction = 1f;
         }
         float deltaX       = speed * Time.deltaTime;
         float newPositionX = tr.localPosition.x + deltaX * direction;
         //Debug.Log("newPositionX:"+newPositionX.ToString());
         tr.localPosition = new Vector3(newPositionX, tr.localPosition.y, tr.localPosition.z);
     }
 }
Ejemplo n.º 16
0
        /// <summary>
        /// Spawn player from server.
        /// </summary>
        /// <param name="location">Coordinates where player should spawn</param>
        /// <param name="player_state">State to put player. Only alive and ready really make sense.</param>
        public void Spawn(Vector4 location, bool isRunner, playerState player_state)
        {
            string pedskin = isRunner ? PedTypes.RandomRunner : PedTypes.Swat;

            this.player.TriggerEvent("sth:spawn", location, pedskin);
            sthvLobbyManager.getPlayerByLicense(player.getLicense()).State = playerState.alive;
        }
Ejemplo n.º 17
0
 void Start()
 {
     rbd2    = GetComponent <Rigidbody2D>();
     anim    = GetComponent <Animator>();
     state   = playerState.IDLE;
     canMove = true;
 }
Ejemplo n.º 18
0
 void startFlight(float deltaForce)
 {
     tr.rigidbody2D.AddForce(new Vector2(0, forceY + deltaForce));
     state        = playerState.flight;
     deltaTimeFly = DateTime.Now;
     isFirstFly   = true;
 }
Ejemplo n.º 19
0
 // Update is called once per frame
 void Update()
 {
     if (Input.GetKeyDown("p") && currentPlayerState == playerState.normal)
     {
         currentPlayerState = playerState.powered;
     }
     else
     {
         currentPlayerState = playerState.normal;
     }
     if (currentEnemyState == enemyState.follow)
     {
         float step = speed * Time.deltaTime;
         //enemy.transform.LookAt(player);
         enemy.transform.position = Vector3.MoveTowards(transform.position, player.position, step);
     }
     if (currentEnemyState == enemyState.runAway)
     {
         float step = -speed * Time.deltaTime;
         enemy.transform.position = Vector3.MoveTowards(transform.position, player.position, step);
     }
     if (currentPlayerState == playerState.normal)
     {
         ;
     }
     {
     }
 }
Ejemplo n.º 20
0
    void FixedUpdate()
    {
        //essentially, we blindly calculate velocities and then apply limits after
        Vector3 velocityChange = Vector3.zero; //zero out velocity to add to each body each PU(physics update)
        float   currVelocityY  = body.velocity.y;

        if (jump_IP)
        {
            state             = playerState.jumping;
            velocityChange.y += jumpVelocity;
            velocityChange.y -= currVelocityY; //stop in air then jump
            FAF = 3;                           //Jump lag
            jumps++;
            jump_IP = false;
        }
        else if (isGrounded)
        {
            jumps   = 0;
            jump_IP = false; //land on ground after clicking jump maxJumps+1 times, don't auto jump
        }
        if (isGrounded)
        {
            groundedPhysics(ref velocityChange);
        }
        else
        {
            airPhysics(ref velocityChange);
        }

        body.AddForce(velocityChange, ForceMode.VelocityChange);
    }
Ejemplo n.º 21
0
    private void FallDown()
    {
        BodyBack.SetActive(true);
        AnimationState animState;

        StopAllCoroutines();
        State = playerState.Fall;
        //TODO: Przenieść do managera animacji
        if (Random.Range(0f, 4f) > 1)
        {
            Jump.CrossFade("Fall");
            animState = Jump.PlayQueued("AfterFall");
        }
        else
        {
            Jump.CrossFade("Fall2");
            animState = Jump.PlayQueued("AfterFall2");
        }
        _rb.gravityScale = 2f;
        if (_currentShadowPrefab != null)
        {
            Destroy(_currentShadowPrefab);
            _currentShadowPrefab = Instantiate(ShadowPrefab2);
        }
        if (!_isOnHill)
        {
            CalculateNotes(GetDistance());
        }
        else
        {
            CalculateNotes(GetDistance(true));
        }
        StartCoroutine(AnimationCooling(animState));
    }
Ejemplo n.º 22
0
    private IEnumerator MakeLanding()
    {
        //TODO: POłączyć z telemarkiem, wybór lądowania uzależniony od miejsca kliknięcia
        BodyBack.SetActive(true);
        State = playerState.DuringTwoLegs;
        Jump.Play("Landing");
        const int  rotatingTime = 7; //Czas obrotu w klatkach
        Vector3    rotateValue;
        Quaternion finalAngle = Quaternion.Euler(new Vector3(0, 0, 335));

        if (transform.eulerAngles.z > 180 && transform.eulerAngles.z < finalAngle.eulerAngles.z)
        {
            rotateValue = new Vector3(0, 0, (Quaternion.Angle(finalAngle, transform.rotation)) / rotatingTime);
        }
        else
        {
            rotateValue = new Vector3(0, 0, -(Quaternion.Angle(finalAngle, transform.rotation)) / rotatingTime);
        }
        rotateValue.z = Mathf.Clamp(rotateValue.z, -6, 6);

        while (Jump.isPlaying)
        {
            if (Quaternion.Angle(finalAngle, transform.rotation) > (rotateValue.z + 1))
            {
                transform.Rotate(rotateValue);
            }
            _animProgress += 1;
            yield return(null);
        }
        State = playerState.LandingTwoLegs;
    }
Ejemplo n.º 23
0
    void Start()
    {
        path.Add(new Vector3(-7.68f, 3.85f));  //0
        path.Add(new Vector3(-7.68f, 1.85f));  //1
        path.Add(new Vector3(-7.68f, -0.15f)); //2
        path.Add(new Vector3(-7.68f, -2.15f)); //3
        path.Add(new Vector3(-7.68f, -4.15f)); //4
        path.Add(new Vector3(-5.5f, 3.85f));   //5
        path.Add(new Vector3(-5.5f, 1.85f));   //6
        path.Add(new Vector3(-5.5f, -0.15f));  //7
        path.Add(new Vector3(-5.5f, -2.15f));  //8
        path.Add(new Vector3(-5.5f, -4.15f));  //9
        path.Add(new Vector3(-3.4f, 3.85f));   //10
        path.Add(new Vector3(-3.4f, 1.85f));   //11
        path.Add(new Vector3(-3.4f, -0.15f));  //12
        path.Add(new Vector3(-3.4f, -2.15f));  //13
        path.Add(new Vector3(-3.4f, -4.15f));  //14
        path.Add(new Vector3(-1.25f, 3.85f));  //15
        path.Add(new Vector3(-1.25f, 1.85f));  //16
        path.Add(new Vector3(-1.25f, -0.15f)); //17
        path.Add(new Vector3(-1.25f, -2.15f)); //18
        path.Add(new Vector3(-1.25f, -4.15f)); //19

        manager = GameObject.Find("GameManager").GetComponent <GameManager>();

        rbd2    = GetComponent <Rigidbody2D>();
        anim    = GetComponent <Animator>();
        state   = playerState.IDLE;
        canMove = true;
    }
Ejemplo n.º 24
0
    //Zone trigger to display Boss's Health Bar
    private void OnTriggerEnter(Collider other)
    {
        if (other.gameObject.tag == "BossZone" && hasTriggeredBoss == false)
        {
            hasTriggeredBoss = true;
            BossHealth.SetActive(true);
            StartCoroutine(bossHealthAnim());
            StartCoroutine(BossMusic());
        }

        /*else if (other.gameObject.tag == "Health")
         * {
         *  pickupSound.Play();
         *  recoverAmount = Random.Range(3.0f, 7.0f);
         *  playerHealth.healDamage(recoverAmount);
         *  Destroy(other.gameObject);
         * }*/

        else if (other.gameObject.tag == "Note")
        {
            rangeOfNote = true;
            setCurrentState(playerState.inspecting);
            previousState = currentState;
            noteTimer     = 0;
        }
    }
Ejemplo n.º 25
0
    private void Land()
    {
        StopAllCoroutines();
        switch (State)
        {
        case playerState.LandingTwoLegs:
            Jump.Play("LandAfterTwoLegs");
            break;

        case playerState.Telemark:
            Jump.Play("LandAfterTelemark");
            break;

        case playerState.DuringTwoLegs:
            Jump.Play("LandDuringTwoLegs");
            break;

        case playerState.DuringTelemark:
            Jump.Play("LandDuringTelemark");
            break;

        default:
            break;
        }
        if (_currentShadowPrefab != null)
        {
            Destroy(_currentShadowPrefab);
            _currentShadowPrefab = Instantiate(ShadowPrefab2);
        }
        CalculateNotes(GetDistance());
        State            = playerState.Finish;
        _rb.gravityScale = 2f;
    }
 //---------------------------------------------------------------------------------------------------------------------------------------------------------------------
 void StateSwitch()
 {
     if (currentState == playerState.fall)
     {
         if (isGrounded)
         {
             currentState = playerState.idle;
         }
     }
     else if (currentState == playerState.idle)
     {
         if (Mathf.Abs(rb.velocity.x) > 1f)
         {
             currentState = playerState.run;
         }
     }
     else if (currentState == playerState.run)
     {
         if (Mathf.Abs(rb.velocity.x) == 0f)
         {
             currentState = playerState.idle;
         }
     }
     else if (currentState == playerState.pain)
     {
         if (damagedTimer <= 0f)
         {
             currentState = playerState.idle;
             damagedTimer = 0f;
         }
     }
 }
Ejemplo n.º 27
0
    public void AddJson()
    {
        //如果資料有誤的話跑提示
        if (GirlName.text == "" || GirlLevel.text == "")
        {
            UnityEditor.EditorUtility.DisplayDialog("System", "確認是否資料有異常??", "Ok");
            return;
        }
        //讀取檔案myJson.json內的資料,命名為 myPlayer
        playerState myPlayer = LoadJson();

        //新增資料至 myPlayer
        myPlayer.GirlName.Add(GirlName.text);
        myPlayer.GirlLevel.Add(int.Parse(GirlLevel.text));

        //將myPlayer轉換成json格式的字串
        string saveString = JsonUtility.ToJson(myPlayer);

        //將字串saveString存到硬碟中
        StreamWriter file = new StreamWriter(Application.dataPath + "/Resources/myJson.json");

        file.Write(saveString);
        file.Close();

        //提示玩家以新增資料
        UnityEditor.EditorUtility.DisplayDialog("System", "已新增資料", "Ok");
    }
Ejemplo n.º 28
0
	// Update is called once per frame
	void Update () {
	   if (Input.GetKeyDown("p")&&currentPlayerState == playerState.normal)
        {
            currentPlayerState = playerState.powered;
        }
       else
        {
            currentPlayerState = playerState.normal;
        }
       if (currentEnemyState == enemyState.follow)
        {
            float step = speed * Time.deltaTime;
            //enemy.transform.LookAt(player);
            enemy.transform.position = Vector3.MoveTowards(transform.position, player.position, step);
        }
        if (currentEnemyState == enemyState.runAway)
        {
            float step = -speed * Time.deltaTime;
            enemy.transform.position = Vector3.MoveTowards(transform.position, player.position, step);
        }
        if (currentPlayerState == playerState.normal);
        {
           
        }

	}
Ejemplo n.º 29
0
    void Start()
    {
        theRB = GetComponent <Rigidbody2D>();

        isRight = true;
        state   = playerState.normal;
    }
 public void BeVictorious()
 {
     GetComponent <NetworkView>().RPC("PlaySFX", RPCMode.All, (int)playerSounds.Victory);
     playerControllable = false;
     lastState          = playerState.PlayerVictory;
     GetComponent <NetworkView>().RPC("LaunchAnimation", RPCMode.All, (int)playerState.PlayerVictory);
 }
Ejemplo n.º 31
0
        /// <summary>
        /// Applies the gravity to the player
        /// </summary>
        protected new void applyGravity()
        {
            if (!_isDebugMode)
            {
                if (Math.Abs(_speedY - 1.5f) < 0.05)
                {
                    _speedY += 1.5f;
                }
                else
                {
                    _speedY += 1.0f;
                }
                // the value shouldn't be greater than the amount of pixel of a tile
                if (_speedY > 15.5f)
                {
                    _speedY = 15.5f;
                }

                _isGrounded = false;
                if (!TryMove(0, _speedY))
                {
                    //The same as: if(speedY > 0) isGrounded=true;
                    //called pipe equals
                    _isGrounded |= _speedY > 0;

                    _wallJumpDirection = 0.0f;
                    _groundHitSpeed    = _speedY;
                    _speedY            = 0;
                    _playerState       = playerState.Idle;
                }
            }
        }
Ejemplo n.º 32
0
    // Update is called once per frame
    void Update()
    {
        inputDevice = InputManager.ActiveDevice;

        if (inputDevice != InputDevice.Null && inputDevice != TouchManager.Device)
        {
            TouchManager.ControlsEnabled = false;
        }

        if (shieldIsActive)
        {
            shield.SetActive(true);
        }
        else
        {
            shield.SetActive(false);
        }
        //  touchControl.ActiveArea.Set(gameObject.transform.position.x - 20.0f, -1.33f, 146.4f, 107.8f);



        if (transform.position.y <= -10.0f)
        {
            playerStates = playerState.Dead;
        }

        if (playerStates == playerState.Dead)
        {
            playerMovement.movementSpeed = 0;
        }
    }
 public WhiteChicken(Texture2D texture, Texture2D texture3, GraphicsDeviceManager graphics)
 {
     sprite = texture;
     healthBar = texture3;
     spriteState = playerState.standing;
     prevSpriteState = playerState.standing;
     spriteEffects = SpriteEffects.FlipHorizontally;
 }
Ejemplo n.º 34
0
    void Start()
    {
        state = playerState.MainMenu;
        text = GetComponent<TextMesh>();
        text.color = colorStart;
        initDict();

        //textManager.LogAllEngWords();
        initSetting();
        hideLeaderboardHUD();
    }
Ejemplo n.º 35
0
	// Update is called once per frame
	void Update () {
            if (Input.GetKeyDown("p") && playerCurrentState == playerState.normal)
            {
                print("Powered");
                playerCurrentState = playerState.powered;
            }
            else
            {
            playerCurrentState = playerState.normal;
            }
        }
Ejemplo n.º 36
0
 public Player(Texture2D texture, SpriteFont font1,GraphicsDeviceManager graphics)
 {
     sprite = texture;
     spriteVisible = true;
     spriteState = playerState.STANDING;
     prevSpriteState = playerState.STANDING;
     position.X = 10;
     position.Y = 550;
     bulletScale = 1.0f;
     ObjectRectangle = new Rectangle();
 }
Ejemplo n.º 37
0
 public Player2(Texture2D texture, SpriteFont font1, GraphicsDeviceManager graphics)
 {
     font = font1;
     sprite = texture;
     spriteVisible = true;
     spriteState = playerState.STANDING;
     prevSpriteState = playerState.STANDING;
     position.X = 100;
     position.Y = 550;
     bulletScale = 1.0f;
     scale = 1.55f;
 }
 public GiantChicken(Texture2D texture, Texture2D texture2, Texture2D texture3, GraphicsDeviceManager graphics)
 {
     sprite = texture;
     bullet = texture2;
     healthBar = texture3;
     position.X = 10;
     position.Y = 550;
     spriteVisible = true;
     spriteState = playerState.standing;
     prevSpriteState = playerState.standing;
     bulletScale = 1.0f;
     spriteEffects = SpriteEffects.FlipHorizontally;
 }
Ejemplo n.º 39
0
    void Start() {
        minimap = GetComponentInChildren<Minimap>();
        Debug.Log("Minimap");
        minimap.gameObject.SetActive(false);
        state = playerState.StageStart;
        //Freeze();
        rb = GetComponent<Rigidbody>();
        result.SetActive(false);
        dead.SetActive(false);
        isAfterClear = false;
        settingBGM();

        //int level = 99;
        //int stage = 99;
        //int min = 80;
        //int sec = 70;
        //Debug.Log(getLeaderboardRecord(90, 90));
        //Debug.Log(getLeaderboardRecord(90, 90)[0] + " " + getLeaderboardRecord(90, 90)[1]);
    }
Ejemplo n.º 40
0
    void Update()
    {

        //Debug.Log("Camera State: " + state);
        if (state == playerState.Moving)
        {
			sm.playSound (SoundManager.soundclip.Dash,0.000000000001f);
            cardboard.transform.position = Vector3.Lerp(cardboard.transform.position, destinationPrime, Time.deltaTime);
            if((destination - cardboard.transform.position).magnitude <= 0.05f)
            {
				sm.stopSound ();
				
                setState(nextState);
                cardboard.transform.position = destination;
            }
        }
        else
        {
            if ((Input.GetKeyDown(KeyCode.A) || Input.GetKeyDown(KeyCode.Alpha2)) && gazed)
            {
                Debug.Log("Scene Var: " + scene);
				sm.playSound (SoundManager.soundclip.PointEnter);

                if(PositionDict.ContainsKey(scene) && StateDict.ContainsKey(scene))
                {
                    nextState = StateDict[scene];
                    moveCameraTo(PositionDict[scene]);
                }
                else if(scene == "bgm")
                {
                    string bgm;
                    bgmToggle.isOn = !bgmToggle.isOn;
                    if (bgmToggle.isOn)
                        bgm = "TRUE";
                    else
                        bgm = "FALSE";
                    PlayerPrefs.SetString("BGM", bgm);

                    updateBGMMute();
                }
                else if (scene == "fx")
                {
                    string fx;
                    fxToggle.isOn = !fxToggle.isOn;
                    if (fxToggle.isOn)
                        fx = "TRUE";
                    else
                        fx = "FALSE";
                    PlayerPrefs.SetString("FX", fx);
                }
                else if (scene == "setting_langugage")
                {
                    if(settingLanguageText.text == "ENGLISH")
                        setLanguage("THAI");
                    if (settingLanguageText.text == "THAI")
                        setLanguage("ENGLISH");
                }
                else
                    LoadMapGenerator(scene);

            }
        }
    }
Ejemplo n.º 41
0
 public void setState(playerState newState)
 {
     nowState = newState;
 }
Ejemplo n.º 42
0
	void Start () {
        _playerState = playerState.idle;
        animator = GetComponent<Animator>();
        direction = new Vector3(0, 0, 0);
        body = GetComponent<Rigidbody2D>();
    }
Ejemplo n.º 43
0
    // Use this for initialization
    void Start () {

        playerCurrentState = playerState.normal;
	}
Ejemplo n.º 44
0
 public void PlayerHealthAdd(int num)
 {
     //this function will trigger hurt or dead
     if (PlayerHealth + num > 100)
         PlayerHealth += 100;
     else if (PlayerHealth + num < 0)
     {
         PlayerHealth = 0;
         spriteState = playerState.DEAD;
     }
     else
     {
         PlayerHealth += num;
         if (num < 0)    // if the number that's passed is negative
             spriteState = playerState.HURT;
     }
 }
Ejemplo n.º 45
0
  //  float step = speed * Time.deltaTime;
    // Use this for initialization
    void Start () {
        currentPlayerState = playerState.normal;
        currentEnemyState = enemyState.follow;
	}
Ejemplo n.º 46
0
	public void ThrowLeaf(Vector3 targetPosition=default(Vector3))
	{
		startThrow = false;

		Debug.Log (transform.parent);
		leafInArms.transform.parent = null;

		leafInArms.GetComponent<Collider2D> ().isTrigger = false;
		leafInArms.GetComponent<MapleLeaf> ().carrier = null;
		if (targetPosition != default(Vector3)) {
			//leafInArms.transform.position = targetPosition;
			leafInArms.GetComponent<Rigidbody2D> ().isKinematic = false;
			leafInArms.GetComponent<Rigidbody2D> ().AddForce (new Vector2 (targetPosition.x - transform.position.x, targetPosition.y - transform.position.y).normalized * (200f * throwLine.localScale.y));
			leafInArms.GetComponent<MapleLeaf> ().isBeingThrown = true;
			leafInArms.GetComponent<MapleLeaf>().thrower = this;
		}
		leafInArms = null;
		pState = playerState.Idle;
		punchResetTime = (Time.time + this.gameObject.transform.GetChild (0).transform.GetChild (0).gameObject.GetComponent<Punch> ().punchRecharge);
	
		throwLine.localScale = new Vector3 (throwLine.localScale.x, 0f, throwLine.localScale.z);
		target.localPosition = new Vector3 (0f, 0f, -10f);
		throwLine.gameObject.SetActive (false);
		target.gameObject.SetActive (false);
	}
Ejemplo n.º 47
0
	public void Stun()
	{
		Debug.Log ("Stunned!");
	
		GameObject starPart = Instantiate (Resources.Load<GameObject> ("Prefabs/StarParticle"), new Vector3(this.transform.position.x, this.transform.position.y, this.transform.position.z),Quaternion.identity) as GameObject;
		starPart.transform.parent = this.transform;
		Destroy (starPart, 3);

		// Set state to punching
		pState = playerState.Stunned;

		switch (playerId) {
		case 1:
			gameManager.soundManager.PlaySound (GameManager.SoundType.bear);
			break;
		case 2:
			gameManager.soundManager.PlaySound (GameManager.SoundType.loon);
			break;
		case 3:
			gameManager.soundManager.PlaySound (GameManager.SoundType.beaver);
			break;
		case 4:
			gameManager.soundManager.PlaySound (GameManager.SoundType.moose);
			break;
		}

		stunStartTime = Time.time;
		leafInArms = null;
	}
Ejemplo n.º 48
0
    public void setState(playerState st)
    {
        state = st;

        switch(state)
        {
            case playerState.MainMenu:
                mainMenu.SetActive(true);
                StartText.SetActive(true);
                SetText.SetActive(true);
                Credit.SetActive(true);
                HowText.SetActive(true);
                cardboard.GetComponent<Rotating>().enabled = true;
                break;

            case playerState.Credit:
                CreditMesh.SetActive(true);
                BackFromCredit.SetActive(true);
                break;

            case playerState.HowToPlay:
                Application.LoadLevel("Training");
                BackFromHowToPlay.SetActive(true);
                break;

            case playerState.Setting:
                SettingMesh.SetActive(true);
                BackFromSetting.SetActive(true);
                break;

		   case playerState.LevelSelect:
				levelSelectMenu.SetActive (true);
                break;

            case playerState.Level1:
                BackFromLevel1.SetActive(true);
                break;

            case playerState.Level2:
                BackFromLevel2.SetActive(true);
                break;

            case playerState.Level3:
                BackFromLevel3.SetActive(true);
                break;
        }
    }
Ejemplo n.º 49
0
 public void moveCameraTo(Vector3 destination)
 {
     Vector3 cameraPosition = cardboard.transform.position;
     destinationPrime = destination * 1.07f - cameraPosition * 0.07f;
     this.destination = destination;
     state = playerState.Moving;
     setAllGameObjectInactive();
 }
Ejemplo n.º 50
0
 private void StateChange(playerState state) {
     anim.SetInteger("GameState", (int)state);
 }
Ejemplo n.º 51
0
	private void Punch()
	{
		Debug.Log ("Punch!");

		// Set state to punching
		pState = playerState.Punching;

		bool zoom = false;

		foreach (PlayerController player in gameManager.activePlayers) {
			if(player != this)
			{
				if(Vector3.Distance(this.gameObject.transform.position, player.gameObject.transform.position) < zoomConstant)
				{
					if(player.pState == playerState.Carrying || player.pState == playerState.Throwing)
					{
						Camera.main.GetComponent<CameraZoom>().ZoomIn(this.gameObject);
						zoom = true;
						break;
					}
				}
			}
		}

		if (!zoom) {
			Camera.main.GetComponent<CameraShake>().Shake();
		}

		// Set vibration intensity to a 
		vibrationIntensity = 200.0f;

		// Play correct sound for correct player
		switch (playerId) {
		case 1:
			gameManager.soundManager.PlaySound (GameManager.SoundType.bear);
			break;
		case 2:
			gameManager.soundManager.PlaySound (GameManager.SoundType.loon);
			break;
		case 3:
			gameManager.soundManager.PlaySound (GameManager.SoundType.beaver);
			break;
		case 4:
			gameManager.soundManager.PlaySound (GameManager.SoundType.moose);
			break;
		}

		this.gameObject.transform.GetChild (0).transform.GetChild (0).gameObject.SetActive (true);
		this.gameObject.transform.GetChild (0).GetComponent<SpriteRenderer> ().sprite = Resources.Load<Sprite> ("Sprites/" + character.ToString () + "_Body_Punch") as Sprite;
		this.gameObject.transform.GetChild (0).transform.GetChild (0).gameObject.GetComponent<Punch> ().punchStartTime = Time.time;
	}
Ejemplo n.º 52
0
        /// <summary>
        /// Applies the gravity, also sets the grounded state.
        /// </summary>
        private void applyGravity()
        {
            //minimum acceleration, makes grounded state not flip out
            if (_velocityY >= 0.0f && _velocityY < 1.0f)
                _velocityY += 1.0f;
            else
                _velocityY += 0.5f;

            //maximum downward velocity, higher then 16 will make you go trough tiles(they have a 16px height)
            if (_velocityY > 16.0f)
                _velocityY = 16.0f;

            //try to move down, if you can't set grounded
            if (move (0, (int)_velocityY) == false) {
                _grounded = true;
                wallJumpDirection = 0.0f;
                _groundHitSpeed = _velocityY;
                _velocityY = 0.0f;
                _playerState = playerState.Idle;
            }
        }
Ejemplo n.º 53
0
	// Update is called once per frame
	void Update () {
		// Set vibration intensity to decrease by half until it reaches 0
		if (vibrationIntensity > 1){
			vibrationIntensity /= 2;
		} else if(vibrationIntensity < 1){
			vibrationIntensity = 0;
		}

		if (gameManager.spawnManager.gameHasStarted) {
//----- HANDLES PLAYER MOVEMENT

			float tempSpeed = movementSpeed;

			if (pState == playerState.Idle || pState == playerState.Carrying) {
				GamePad.SetVibration (WindowsCheckControllerToVibrate (), 0, 0);
			}

			if (pState == playerState.Carrying || pState == playerState.Throwing) {
				tempSpeed *= 0.9f;
			}

			if (pState != playerState.Stunned) {
				movementVector.x = Input.GetAxis (("LeftJoystickX" + playerId).ToString ()) * tempSpeed;
				movementVector.y = Input.GetAxis (("LeftJoystickY" + playerId).ToString ()) * tempSpeed * -1;

				//Debug.Log (playerId + " " + Input.GetAxis (("RightTrigger" + playerId).ToString ()));

				this.gameObject.transform.GetChild (0).gameObject.transform.localEulerAngles = new Vector3 (0, 0, Mathf.Rad2Deg * (Mathf.Atan2 (movementVector.y, movementVector.x)) - 270f);

				movementVector.x = Mathf.Lerp (rb.velocity.x, movementVector.x, dragConstant);
				movementVector.y = Mathf.Lerp (rb.velocity.y, movementVector.y, dragConstant);

				rb.velocity = movementVector;
				this.gameObject.transform.localEulerAngles = new Vector3 (0f, 0f, 0f);
			} else {
				vibrationIntensity = 100.0f;

				GamePad.SetVibration (WindowsCheckControllerToVibrate (), vibrationIntensity, vibrationIntensity);

				if (Time.time > (stunStartTime + playerManager.stunDuration)) {
					pState = playerState.Idle;

					GamePad.SetVibration (WindowsCheckControllerToVibrate (), 0, 0);
				}
			}

//----- HANDLES PLAYER ACTION
			if(!gameManager.inGodMode)
			{
				if (Input.GetAxis (("RightTrigger" + playerId).ToString ()) > 0f) {
					// Actual vibration
					GamePad.SetVibration (WindowsCheckControllerToVibrate (), vibrationIntensity, vibrationIntensity);

					if (Time.time > punchResetTime) {
						switch (pState) {
						case playerState.Idle:
						//punch
							Punch ();
							break;
						case playerState.Carrying:
							pState = playerState.Throwing;
							startThrow = true;
							throwStartTime = Time.time;
							break;
						case playerState.Punching:
						//nothing
							break;
						case playerState.Stunned:
						//nothing
							break;
						case playerState.Throwing:
						//nothing
							break;
						}
					}
				} else if (startThrow) {
					if (target.gameObject.activeSelf) {
						ThrowLeaf (target.position);
					} else {
						ThrowLeaf ();
					}
				}

				if (startThrow && (Time.time > (throwStartTime + timeBeforeThrowBegins))) {
					throwLine.gameObject.SetActive (true);
					target.gameObject.SetActive (true);
				
					throwLine.localScale = new Vector3 (throwLine.localScale.x, throwLine.localScale.y + 0.1f, throwLine.localScale.z);
					target.localPosition = new Vector3 (0f, -3.4f * throwLine.localScale.y, -10f);
				}
			}

			if(leafInArms == null && (pState == playerState.Throwing || pState == playerState.Carrying))
			{
				pState = playerState.Idle;
				MapleLeaf brokenLeaf = GetComponentInChildren<MapleLeaf>();
				brokenLeaf.carrier = null;
				brokenLeaf.transform.parent = null;

			}
		}
	}
Ejemplo n.º 54
0
        /// <summary>
        /// Applies the player movement according to user input.
        /// </summary>
        private void applyPlayerMovement()
        {
            if (Input.GetKey (Key.LEFT)) {
                if (!Input.GetKey (Key.RIGHT) && move (-_moveSpeed, 0) == true) {
                    if (_grounded) {
                        _playerState = playerState.Running;
                    }
                    scaleX = -1;
                    SetOrigin (width-1, 0);
                } else if (!_grounded && (_velocityY > 2.0f || Input.GetKeyDown (Key.SPACE) || Input.GetKeyDown (Key.UP))) {
                    _playerState = playerState.Sliding;
                }
            }

            if (Input.GetKey (Key.RIGHT)) {
                if (!Input.GetKey (Key.LEFT) && move (_moveSpeed, 0) == true) {
                    if (_grounded) {
                        _playerState = playerState.Running;
                    }
                    scaleX = 1;
                    SetOrigin (0, 0);
                } else if (!_grounded && (_velocityY > 2.0f || Input.GetKeyDown (Key.SPACE) || Input.GetKeyDown (Key.UP))) {
                    _playerState = playerState.Sliding;
                }

            }

            if ((Input.GetKeyDown (Key.UP) || Input.GetKeyDown (Key.Z) || Input.GetKeyDown (Key.SPACE)) && _grounded) {
                _velocityY -= 6.0f;

            }
        }
Ejemplo n.º 55
0
Archivo: Player.cs Proyecto: Chobin/SP
 public bool Jump(GameTime currentTime)
 {
     if (currentPlayerState != playerState.POSTJUMP || (jumpNum < 1 && currentTime.TotalGameTime - nextAvailableJump > JUMP_TIMELIMIT))
     {
         nextAvailableJump = currentTime.TotalGameTime;
         currentPlayerState = playerState.POSTJUMP;
         speedY = 3.5f;
         jumpNum++;
         if (jumpNum == 2)
             jumpNum = 0;
         return true;
     }
     return false;
 }
Ejemplo n.º 56
0
        void Update()
        {
            //if level isn't visible stop movement
            if (parent != null && !parent.visible)
                return;

            //if sliding play sliding sound
            if (_playerState == playerState.Sliding) {
                _slideChannel.IsPaused = false;
            } else {
                _slideChannel.IsPaused = true;
            }

            //if running play running sound
            if (_playerState == playerState.Running) {
                _footStepChannel.IsPaused = false;
            } else {
                _footStepChannel.IsPaused = true;
            }

            //stop player movement if dead
            if (!_isDead) {
                _grounded = false;
                _frame += 0.5f;

                checkSpecialColisions ();

                //fallback playerstate
                _playerState = playerState.InAir;

                applyGravity ();
                applyPlayerMovement ();

                switch (_playerState) {
                case playerState.Idle:
                    Idle ();
                    break;
                case playerState.Running:
                    Running ();
                    break;
                case playerState.InAir:
                    InAir ();
                    break;
                case playerState.Sliding:
                    Sliding ();
                    break;

                }
                wallJump ();

            }
            checkDamage ();
        }
Ejemplo n.º 57
0
        public void resetPlayer()
        {
            _score = 0;
            _isDead = false;
            _playerState = playerState.Idle;

            _moveSpeed = 4;
            _frame = 0.0f;
            _grounded = false;
            SetFrame (1);
        }
Ejemplo n.º 58
0
        public void Frames(GameTime time)
        {
            gameTime = time;
            switch (spriteState)
            {
                #region case: STANDING
                case playerState.STANDING:
                    if (spriteState != prevSpriteState)
                    {
                        frames = 0;
                        elapsed = 0;
                        //if (Player1PreviousState == playerState.PUNCHING && flip1)
                        //    DestinationRectangle1.X += 40;
                        prevSpriteState = spriteState;
                    }
                    elapsed += (float)gameTime.ElapsedGameTime.TotalMilliseconds;
                    if (elapsed >= Homer.standing.delay)
                    {
                        if (frames >= (Homer.standing.numOfFrames - 1))
                            frames = 0;
                        else
                            frames++;
                        elapsed = 0;
                    }
                    break;
                #endregion
                #region case: WALKING
                case playerState.WALKING:
                    if (spriteState != prevSpriteState)
                    {
                        frames = 0;
                        elapsed = 0;
                        prevSpriteState = spriteState;
                    }
                    elapsed += (float)gameTime.ElapsedGameTime.TotalMilliseconds;
                    if (elapsed >= Homer.walking.delay)
                    {
                        if (frames >= (Homer.walking.numOfFrames - 1))
                            frames = 0;
                        else
                            frames++;
                        elapsed = 0;
                    }
                    break;
                #endregion
                #region case: FIRING
                case playerState.FIRING:
                    if (spriteState != prevSpriteState)
                    {
                        //fireBall.Play();
                        //FireBall1_CurrentState_Active = true;
                        frames = 0;
                        elapsed = 0;
                        prevSpriteState = spriteState;
                    }
                    elapsed += (float)gameTime.ElapsedGameTime.TotalMilliseconds;
                    if (elapsed >= Homer.firing.delay)
                    {
                        if (frames != Homer.firing.numOfFrames - 1)
                        {
                            frames++;
                            elapsed = 0;
                        }
                    }
                    if ((frames == Homer.firing.numOfFrames - 1) && (elapsed >= Homer.firing.delay + 200f))
                    {
                        frames = 0;
                        spriteState = playerState.STANDING;
                    }
                    break;
                #endregion
                #region case: HURT
                case playerState.HURT:
                    if (spriteState != prevSpriteState)
                    {
                        frames = 0;
                        elapsed = 0;
                        prevSpriteState = spriteState;
                        // = hurtamount
                    }
                    elapsed += (float)gameTime.ElapsedGameTime.TotalMilliseconds;
                    if (elapsed >= Homer.hurt.delay)
                    {
                        if (frames != Homer.hurt.numOfFrames - 1)
                        {
                            if (spriteEffects == SpriteEffects.None)
                                position.X -= 30;
                            else
                                position.X += 30;
                            frames++;
                            elapsed = 0;
                        }
                    }
                    if ((frames == Homer.hurt.numOfFrames - 1) && (elapsed >= Homer.hurt.delay + 200f))
                    {
                        frames = 0;
                        spriteState = playerState.STANDING;
                    }
                    break;
                #endregion
                #region case: DEAD
                case playerState.DEAD:
                    if (spriteState != prevSpriteState)
                    {
                        frames = 0;
                        elapsed = 0;
                        prevSpriteState = spriteState;
                    }
                    elapsed += (float)gameTime.ElapsedGameTime.TotalMilliseconds;
                    if (elapsed >= Homer.dead.delay)
                    {
                        if (frames < (Homer.dead.numOfFrames - 1))
                        {
                            if (spriteEffects == SpriteEffects.None)
                                position.X -= 50;
                            if (spriteEffects == SpriteEffects.FlipHorizontally)
                                position.X += 50;
                            frames++;
                        }
                        elapsed = 0;
                    }
                    break;
                #endregion
                default:
                    break;
            }
            //switch (PlayerHealth)
            //{

            //}
        }
Ejemplo n.º 59
0
 // Use this for initialization
 void Start()
 {
     nowState = playerState.stop;
 }
Ejemplo n.º 60
0
 public static void SetState(playerState state) {
     State = state;
     OnStateChanged(state);
 }