Example #1
0
    public IEnumerator Player_AttackR()
    {
        while (currentState == PLAYER_STATE.ATTACKR)
        {
            //Rotation
            m_PlayerTrans.transform.rotation = Quaternion.Slerp(m_PlayerTrans.transform.rotation, Quaternion.LookRotation(m_Direction), rotSpeed);
            m_Direction   = m_Red.position - m_PlayerTrans.transform.position;
            m_Direction.y = 0.0f;


            if (IsPointerOverUIObject())
            {
                m_Anim.SetBool("Idle", false);
                m_Anim.SetBool("Move", false);
                m_Anim.SetBool("AttackL", false);
                m_Anim.SetBool("AttackR", true);
                m_Anim.SetBool("Defend", false);
            }

            yield return(null);

            CurrentState = PLAYER_STATE.IDLE;
        }

        yield break;
    }
Example #2
0
    /// <summary>
    /// 플레이어 컨트롤러 스테이트 머신
    /// </summary>
    public void Set_StateMachine(PLAYER_STATE nextState)
    {
        _prevState = _myState;
        _myState   = nextState;

        if (_currHP <= 0)
        {
            _myState = PLAYER_STATE.DEAD;
        }

        switch (nextState)
        {
        default:
            StartCoroutine(IE_BaseController());
            break;

        case PLAYER_STATE.ATTACK:
            StartCoroutine(IE_AttackController());
            break;

        case PLAYER_STATE.CAST:
            //StartCoroutine(IE_CastController());
            break;

        case PLAYER_STATE.DEAD:
            _mainCamera.GetComponent <CameraFilter>().setGray = true;
            _animator.gameObject.SetActive(false);
            if (photonView.IsMine)
            {
                PhotonNetwork.Instantiate("Grave", transform.position, _animator.transform.rotation);
            }
            break;
        }
    }
    private void CheckGrounded()
    {
        RaycastHit2D raycastHit = Physics2D.BoxCast(new Vector2(collider.bounds.center.x, collider.bounds.center.y - collider.bounds.extents.y), new Vector2(collider.bounds.extents.x * 2, groundedGraceDistance), 0, Vector2.down, 0, groundLayerMask);

        if (raycastHit.collider != null && rBody.velocity.y <= 0) //Je deteste utiliser velocity pour ca, si vous avez des solutions alternatives dites-moi
        {
            isGrounded    = true;
            currentCoyote = coyoteTime;
            if (state == PLAYER_STATE.AIRBORNE)
            {
                AudioJumpLanding.Play();
                // Debug.Log("tg");

                state = PLAYER_STATE.GROUNDMOVING;
                isDoubleJumpAvailable = true;
            }
        }
        else
        {
            if (currentCoyote <= 0)
            {
                isGrounded = false;
            }
        }

        ///See the grace distance in the scene view
        //Debug.DrawRay(collider.bounds.center, Vector2.down*(collider.bounds.extents.y + groundedGraceDistance), Color.green);
    }
    // Update is called once per frame
    void Update()
    {
        if (ATK_TIMER_ACTIVE == false) {
            if ( PlayerState == PLAYER_STATE.Attacking ){
                ATK_TIMER_ACTIVE = true ;
            }
        } else {
            ATK_TIMER += Time.deltaTime  ;
        }
        if (GetComponent<Animator>().GetCurrentAnimatorStateInfo(0).IsName("Idle") && PlayerState == PLAYER_STATE.Attacking && ATK_TIMER > 0.3f ) {
            PlayerState = PLAYER_STATE.Idle;
            ATK_TIMER = 0 ;
            ATK_TIMER_ACTIVE = false;
            Debug.Log (GetComponent<Animator>().GetCurrentAnimatorStateInfo(0).fullPathHash);
        }

        switch ( PlayerState ) {
        case PLAYER_STATE.Idle:

                break;

        case PLAYER_STATE.Walking:

                break;

        case PLAYER_STATE.Attacking:

                break;
            }
    }
Example #5
0
    public IEnumerator Player_Defend()
    {
        while (currentState == PLAYER_STATE.DEFEND)
        {
            Vector3 relativePos = m_Red.transform.position - this.transform.position;

            if (IsPointerOverUIObject())
            {
                //Quaternion lookAtTarget = Quaternion.LookRotation(relativePos);
                //this.transform.rotation = lookAtTarget;

                //Rotation
                m_PlayerTrans.transform.rotation = Quaternion.Slerp(m_PlayerTrans.transform.rotation, Quaternion.LookRotation(m_Direction), rotSpeed);
                m_Direction   = m_Red.position - m_PlayerTrans.transform.position;
                m_Direction.y = 0.0f;

                m_Anim.SetBool("Idle", false);
                m_Anim.SetBool("Move", false);
                m_Anim.SetBool("AttackL", false);
                m_Anim.SetBool("AttackR", false);
                m_Anim.SetBool("Defend", true);
            }

            yield return(new WaitForSeconds(1));

            CurrentState = PLAYER_STATE.IDLE;
        }

        yield break;
    }
Example #6
0
 public void Move()
 {
     if (Input.GetKey(KeyCode.LeftArrow))
     {
         directionCheck = false;
         state          = PLAYER_STATE.LEFT;
         transform.Translate(Vector3.left * speed * Time.deltaTime);
     }
     if (Input.GetKey(KeyCode.RightArrow))
     {
         directionCheck = true;
         state          = PLAYER_STATE.RIGHT;
         transform.Translate(Vector3.right * speed * Time.deltaTime);
     }
     if (Input.GetKey(KeyCode.UpArrow))
     {
         state = PLAYER_STATE.UP;
         transform.Translate(Vector3.up * speed * Time.deltaTime);
     }
     if (Input.GetKey(KeyCode.DownArrow))
     {
         state = PLAYER_STATE.DOWN;
         transform.Translate(Vector3.down * speed * Time.deltaTime);
     }
     if (!Input.anyKey)
     {
         state = PLAYER_STATE.STOP;
     }
 }
Example #7
0
 void ReadActionInput()
 {
     if (Input.GetButtonDown("Fire1"))
     {
         int lockNumber = Random.Range(0, 100);
         if (this.GetComponent <Chill>().Activate(lockNumber))
         {
             actionLockNumber = lockNumber;
             state            = PLAYER_STATE.DOING_ACTION;
         }
     }
     //HAUNT
     else if (Input.GetButtonDown("Fire2"))
     {
         int lockNumber = Random.Range(0, 100);
         if (this.GetComponent <Haunt>().Activate(lockNumber))
         {
             this.GetComponent <Animator>().Play("Magic 01");
             actionLockNumber = lockNumber;
             state            = PLAYER_STATE.DOING_ACTION;
         }
     }
     else if (Input.GetButtonDown("Fire3"))
     {
         int lockNumber = Random.Range(0, 100);
         if (this.GetComponent <Shout>().Activate(lockNumber))
         {
             actionLockNumber = lockNumber;
             state            = PLAYER_STATE.DOING_ACTION;
         }
     }
 }
Example #8
0
        public void sync(Player o)
        {
            id      = o.id;
            name    = o.name;
            state   = o.state;
            message = o.message;
            ai      = o.ai;
            for (int i = 0; i < items.Length; i++)
            {
                items[i] = o.items[i];
            }
            //
            fdead              = o.fdead;
            deadReason         = o.deadReason;
            deadid             = o.deadid;
            discoverer         = o.discoverer;
            murderer           = o.murderer;
            murdererTurn       = o.murdererTurn;
            dayDiscovere       = o.dayDiscovere;
            dayDead            = o.dayDead;
            dayKill            = o.dayKill;
            dayMurdererSuccess = o.dayMurdererSuccess;
            dayUseItem         = o.dayUseItem;

            dayNoonCount = o.dayNoonCount;
            dayNightVote = o.dayNightVote;
            dayMidKnifeP = o.dayMidKnifeP;
            //
            net_opp  = o.net_opp;
            net_item = o.net_item;
        }
    // Update is called once per frame
    void Update()
    {
        /*
         * animator.SetBool("left", false);
         * animator.SetBool("right", false);
         * animator.SetBool("up", false);
         * animator.SetBool("down", false);
         * switch (player_behaviour.p_dir_state)
         * {
         *  case (PLAYER_DIRECTION.P_UP):
         *      animator.SetBool("up", true);
         *      break;
         *  case (PLAYER_DIRECTION.P_DOWN):
         *      animator.SetBool("down", true);
         *      break;
         *  case (PLAYER_DIRECTION.P_RIGHT):
         *      animator.SetBool("right", true);
         *      break;
         *  case (PLAYER_DIRECTION.P_LEFT):
         *      animator.SetBool("left", true);
         *      break;
         * }
         */
        animator.SetBool("boomerang_available", player_behaviour.p_boomerang_current == 0);
        if (prev_state != player_behaviour.p_state || prev_dir != player_behaviour.p_dir_state)
        {
            StateChange();
        }

        prev_state = player_behaviour.p_state;
        prev_dir   = player_behaviour.p_dir_state;
    }
Example #10
0
        private void EnterState(PLAYER_STATE state)
        {
            switch (state)
            {
            case PLAYER_STATE.PCS_NORMAL:
                currentSpeed = normalSpeed;

                sprite     = GraphicsManager.Instance.charFine;
                dimensions = normalSize;
                break;

            case PLAYER_STATE.PCS_WET:
                currentSpeed = wetMovementSpeed;

                sprite     = GraphicsManager.Instance.charNotFine;
                dimensions = wetSize;

                dampnessTimer = EventManager.Instance.AddTimer(3.0f, new TimedEvent(EventStopDamp));
                break;

            case PLAYER_STATE.PCS_POWEREDUP:
                currentSpeed = normalSpeed;

                sprite     = GraphicsManager.Instance.charArmoured;
                dimensions = normalSize;
                break;
            }
        }
Example #11
0
 public void GoalFlugSwitch()
 {
     goalUi.GetComponent <Renderer>().enabled = true;
     state = PLAYER_STATE.GOAL;
     //リザルト遷移の準備
     GameObject.Find("resultManager").GetComponent <ResultManagerScript>().OfflinePlayerGoal(this.gameObject);
 }
 void OnCollisionEnter2D(Collision2D col)
 {
     if (col.collider.tag == "Stage")
     {
         this.playerState = PLAYER_STATE.IDLE;
     }
 }
Example #13
0
    // 两个状态是否可以共存
    protected bool canCoExist(PLAYER_STATE state0, PLAYER_STATE state1)
    {
        // 任意一个状态没有所属组,则不在同一组
        if (!mStateGroupList.ContainsKey(state0) || !mStateGroupList.ContainsKey(state1))
        {
            return(true);
        }
        List <STATE_GROUP> group0 = mStateGroupList[state0];
        List <STATE_GROUP> group1 = mStateGroupList[state1];
        int count0 = group0.Count;
        int count1 = group1.Count;

        for (int i = 0; i < count0; ++i)
        {
            for (int j = 0; j < count1; ++j)
            {
                // 属于同一状态组,并且该状态组中的所有状态都不能共存
                if (group0[i] == group1[j] && !mGroupStateList[group0[i]].mCoexist)
                {
                    return(false);
                }
            }
        }
        return(true);
    }
 void OnCollisionExit2D(Collision2D col)
 {
     if (col.collider.tag == "Stage")
     {
         this.playerState = PLAYER_STATE.AIRBORNE;
     }
 }
Example #15
0
    void EndJump()
    {
        if (normal_gravity)
        {
            rb.gravityScale += 1.0f;
            normal_gravity   = false;
        }

        if (IsCollidingWithGround())
        {
            if (!normal_gravity)
            {
                rb.gravityScale -= 1.0f;
                normal_gravity   = true;
            }

            jump_time_counter = 0.0f;
            player_state      = PLAYER_STATE.GROUNDED;

            Anim.SetBool("Jumping", false);
            Anim.SetBool("Falling", false);

            //Debug.Log("JUMP ENDED");
        }
    }
Example #16
0
 void OnTriggerEnter2D(Collider2D other)
 {
     if (other.CompareTag("Respawn"))
     {
         player_state = PLAYER_STATE.DEAD;
     }
 }
Example #17
0
    // 敵にあたった時
    public void PlayerDamage()
    {
        switch (State)
        {
        case PLAYER_STATE.PLAYER_NORMAL:
            PlayerDead();
            break;

        case PLAYER_STATE.PLAYER_SUPER:
            // プレイヤーパワーダウンSEの再生
            PlayerSE.PlayerSEPlay(PlayerSEManager.PLAYER_SE_LABEL.PLAYER_SE_PAWER_DOWN);
            State = PLAYER_STATE.PLAYER_NORMAL;
            break;

        case PLAYER_STATE.PLAYER_FIRE:
            // プレイヤーパワーダウンSEの再生
            PlayerSE.PlayerSEPlay(PlayerSEManager.PLAYER_SE_LABEL.PLAYER_SE_PAWER_DOWN);
            State = PLAYER_STATE.PLAYER_NORMAL;
            break;

        default:
            break;
        }

        SetState(State);
    }
Example #18
0
 void Start()
 {
     playerState = PLAYER_STATE.BASIC;
     animator    = GetComponent <Animator>();
     isDie       = false;
     maxhealth   = health;
 }
    // Use this for initialization
    void Start()
    {
        Debug.unityLogger.logEnabled = false;
        playerState   = PLAYER_STATE.NORMAL;
        faceLeft      = true;
        stateTime     = 0;
        rb            = GetComponent <Rigidbody>();
        leftKeyState  = 0;
        rightKeyState = 0;
        col           = gameObject.GetComponent <CollisionCount>();

        //m_score.SetScore(0);
        m_rank.DetermineRANK(m_rank.GetLowest());

        m_playerStatus = new Status();
        SetStatus();
        m_item          = gameObject.AddComponent <Item>();
        m_nowItemNumber = 0;
        m_outFlag       = false;

        m_currentPos = transform.position;

        m_currentVec = new Vector3(0, 0, 0);
        m_downFlag   = false;
        goalFlag     = false;
    }
Example #20
0
    public IEnumerator Player_Attack()
    {
        while (currentState == PLAYER_STATE.ATTACK)
        {
            foreach (AnimatorControllerParameter parameter in m_Anim.parameters)
            {
                if (parameter.type == AnimatorControllerParameterType.Bool)
                {
                    m_Anim.SetBool(parameter.name, false);
                }
            }


            m_Anim.SetBool("AttackL", true);


            yield return(null);

            m_Anim.SetBool("AttackL", false);
        }

        CurrentState = PLAYER_STATE.IDLE;

        yield break;
    }
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.A)) //testing animation state switching
        {
            Debug.Log("Now in idle");
            state = PLAYER_STATE.S_IDLE;
        }

        if (Input.GetKeyDown(KeyCode.S)) //testing animation state switching
        {
            Debug.Log("Now in jump");
            state = PLAYER_STATE.S_JUMP;
        }

        if (Input.GetKeyDown(KeyCode.D)) //testing animation state switching
        {
            Debug.Log("Now in walk");
            state = PLAYER_STATE.S_WALK;
        }

        switch (state)
        {
        case PLAYER_STATE.S_IDLE:     //idle state
            anim.SetTrigger("IDLE");
            break;

        case PLAYER_STATE.S_JUMP:     //jump state
            anim.SetTrigger("JUMP");
            break;

        case PLAYER_STATE.S_WALK:     //walk state
            anim.SetTrigger("WALK");
            break;
        }
    }
Example #22
0
    /*******************************************************************
    * * 動きの処理
    * *****************************************************************/
    void PlayerMove()
    {
        // ロボットが空中にいたらこれ以降処理を読まない
        if (!isGround)
        {
            return;
        }

        this.cameraDirection = Vector3.Scale(mCamera.transform.forward, new Vector3(1, 0, 1)).normalized;                   // カメラの方向から、X-Z平面の単位ベクトルを取得

        if (horizontal != 0 || vertical != 0)
        {
            this.moveDirection  = (cameraDirection * vertical + mCamera.transform.right * horizontal).normalized;
            transform.rotation  = Quaternion.LookRotation(moveDirection);                                                   // キャラクターの向きを進行方向に
            this.moveDirection *= walkSpeed;
            this.AniState       = ANIMATION_STATE._WALK_ANIMATION;
        }
        else
        {
            this.AniState      = ANIMATION_STATE._IDLE_ANIMATION;
            this.moveDirection = Vector3.zero;                                      // 移動方向初期化
            rigidBody.velocity = Vector3.zero;                                      // 移動量初期化
        }

        // Yボタンが押されたらロボットを稼働停止にさせる
        if (xboxInput.Check(XboxInput.KEYMODE.DOWN, XboxInput.PAD.KEY_Y))
        {
            playerState = PLAYER_STATE._STOP;
            return;
        }

        this.rigidBody.velocity = moveDirection * Time.deltaTime;                   // 速度設定

        CheckJumping();                                                             // ジャンプできるか調べる
    }
Example #23
0
    private void climb( )
    {
        if (transform.position.y > (_hit_object.transform.position.y + (_hit_object.transform.localScale.y)))
        {
            if (_player_state == PLAYER_STATE.PLAYER_STATE_CLIMB)
            {
                _climbed_normal = true;
            }
            if (_player_state == PLAYER_STATE.PLAYER_STATE_CLIMB_HIGH)
            {
                _climbed_high = true;
            }
            gameObject.GetComponent <Rigidbody> ().useGravity = true;
            _player_state = PLAYER_STATE.PLAYER_STATE_STAY;
        }
        float move_y = ((_hit_object.transform.position.y + _hit_object.transform.localScale.y) - (_last_ground_pos.y - transform.localScale.y)) / 100;

        move_y *= clim_speed;
        Vector3 pos = _hit_object.transform.position - gameObject.transform.position;

        pos.Normalize();
        pos  *= 0.03f;
        pos.y = move_y;
        pos  += transform.position;
        transform.position = pos;
    }
Example #24
0
    /*******************************************************************
    * * ロボットがジャンプできるか調べる処理
    * *****************************************************************/
    void CheckJumping()
    {
        // Rayを生成
        this.ray   = new Ray(transform.position + Vector3.up / 2, transform.forward);
        this.upRay = new Ray(transform.position + Vector3.up * 2, transform.forward);
        //// Rayを視覚的に描画
        //Debug.DrawRay(ray.origin, ray.direction * RAY_LENGTH, Color.blue);
        //Debug.DrawRay(upRay.origin, upRay.direction * RAY_LENGTH, Color.red);

        // ロボットの前方にあるRayがHitし、ロボットの上方にあるRayがHitしていなければ
        if (Physics.Raycast(ray, out rayHit, RAY_LENGTH, jumpLayerMask) && !Physics.Raycast(upRay, RAY_LENGTH))
        {
            // Bボタンでジャンプ処理
            if (xboxInput.Check(XboxInput.KEYMODE.DOWN, XboxInput.PAD.KEY_B))
            {
                // スタート地点、中間地点、最終地点の座標格納
                this.startPoint = transform.position;
                this.wayPoint   = (transform.position + rayHit.transform.position) * 0.5f + Vector3.up * jumpForce;
                this.endPoint   = rayHit.transform.position + Vector3.up * 2;
                // スピード初期化、目的地にプレイヤーを向ける、ジャンプ状態へ
                this.moveDirection      = Vector3.zero;
                this.rigidBody.velocity = Vector3.zero;
                Vector3 dir = (rayHit.transform.position - transform.position).normalized;
                transform.rotation = Quaternion.LookRotation(new Vector3(dir.x, 0.0f, dir.z));
                this.playerState   = PLAYER_STATE._JUMP;
            }
        }
    }
Example #25
0
    // Update is called once per frame
    void Update()
    {
        updateGauge();
        setRunEffect( );
        setAnimation( );
        checkClimb( );

        if (_player_state == PLAYER_STATE.PLAYER_STATE_RUN ||
            _player_state == PLAYER_STATE.PLAYER_STATE_STAY)
        {
            move();
            _last_ground_pos = transform.position;
        }
        if (_player_state == PLAYER_STATE.PLAYER_STATE_CLIMB ||
            _player_state == PLAYER_STATE.PLAYER_STATE_CLIMB_HIGH)
        {
            climb();
        }
        AnimatorStateInfo state = _animator.GetCurrentAnimatorStateInfo(0);

        if (_gauge <= 0)
        {
            _player_state = PLAYER_STATE.PLAYER_STATE_DEAD;
        }
        if (_clear)
        {
            _player_state = PLAYER_STATE.PLAYER_STATE_CLEAR;
        }
        if (_clear || _gauge <= 0)
        {
            _game_end_time++;
        }
    }
Example #26
0
    public bool addState(PLAYER_STATE type, StateParam param)
    {
        if (mCurStateList.ContainsKey(type))
        {
            return(false);
        }
        // 创建状态,并且判断是否可以进入该状态,不能进入则直接返回
        PlayerState state = createState(type);

        state.setPlayer(mPlayer);
        if (!state.canEnter())
        {
            return(false);
        }
        // 先移除不能共存的状态
        Dictionary <PLAYER_STATE, PlayerState> tempList = new Dictionary <PLAYER_STATE, PlayerState>(mCurStateList);

        foreach (var item in tempList)
        {
            if (!canCoExist(item.Key, type))
            {
                removeState(item.Key);
            }
        }
        // 进入状态,并添加到状态列表
        state.enter(param);
        mCurStateList.Add(type, state);
        // 通知角色有状态添加
        mPlayer.notifyStateChanged();
        return(true);
    }
Example #27
0
    public void GoalFlugSwitch()
    {
        if (!isLocalPlayer)
        {
            return;
        }

        //自分の状態をゴールに。
        state = PLAYER_STATE.GOAL;

        goalUi.GetComponent <Renderer>().enabled = true;

        //リザルト遷移の準備
        GameObject.Find("resultManager").GetComponent <ResultManagerScript>().PlayerGoal(this.gameObject, isServer);

        ////ネットワークでゴールした事を送信(ホストとクライアントで分けているのは仕様上仕方ない。)
        //クライアントだけでもいいが、途中でホストがネットワークを切った時の事を考えて互いに送信し合うことにした。
        //クライアント
        if (!isServer)
        {
            CmdProvideGoalToServer();
        }
        //ホスト
        else
        {
            RpcProvidePositionToServer();
        }
    }
    public bool isTeleporting = false;     // Currently teleporting (to block movement etc)


    // Use this for initialization
    void Start()
    {
        if ((movementHandler = GetComponent <Player_Movement>()) == null)
        {
            Debug.LogError("You need to add a player movement script to this game object");
        }

        if ((animationHandler = GetComponent <Player_Animation_Controller>()) == null)
        {
            Debug.LogError("You need to add a player animation handler script to this game object");
        }

        if ((manager = GameObject.FindGameObjectWithTag("GameManager").GetComponent <Game_Manager>()) == null)
        {
            Debug.LogError("You're missing a Game Manager with a game manager script in your scene");
        }

        if ((inventoryHandler = GetComponent <Player_Inventory>()) == null)
        {
            Debug.LogError("You need to add a player inventory script to this game object");
        }

        if ((GameObject.FindGameObjectWithTag("Hand") == null))
        {
            Debug.LogError("You need to add a hand tag to a part of the player body (weapon pickup)");
        }

        height = GetComponent <MeshRenderer> ().bounds.size.y;
        state  = PLAYER_STATE.ALIVE;

        transform.position = determineRespawnPos(spawnPos.position, 15);
    }
    public IEnumerator Player_Defend()
    {
        while (currentState == PLAYER_STATE.DEFEND)
        {
            Vector3 relativePos = m_Red.transform.position - this.transform.position;

            if (IsPointerOverUIObject())
            {
                Quaternion lookAtTarget = Quaternion.LookRotation(relativePos);
                this.transform.rotation = lookAtTarget;
                m_Anim.SetBool("Idle", false);
                m_Anim.SetBool("Move", false);
                m_Anim.SetBool("AttackL", false);
                m_Anim.SetBool("AttackR", false);
                m_Anim.SetBool("Defend", true);

                yield return(new WaitForSeconds(0.88f));

                CurrentState = PLAYER_STATE.IDLE;
            }

            yield return(null);
        }

        yield break;
    }
Example #30
0
    // Use this for initialization
    void Start()
    {
        velocity    = Vector3.zero;
        time        = 0;
        state       = PLAYER_STATE.STOP;
        bJump       = false;
        bDoubleJump = false;
        bHitWall    = false;

        resultTimer = 0;

        camera = GameObject.Find("Main Camera");
        //カメラの更新
        camera.GetComponent <cameraController>().SetCamera();

        //ぷにコンの長さを取得するため、コントローラーマネージャ取得
        Scr_ControllerManager = GameObject.Find("PuniconCamera/ControllerManager");

        Score = GameObject.Find("ScoreManager");

        //テキストの変更
        speedText.text = "Speed: " + speed.ToString();

        //エフェクト
        smog.Stop();

        anim       = GetComponent <Animator>();
        anim.speed = 1.0f;

        //SE
        se = GameObject.Find("SEManager").GetComponent <SEManager>();

        startRenderer = startUi.GetComponent <Renderer>();
    }
Example #31
0
    void OnTriggerEnter(Collider col)
    {
        if (col.gameObject.tag == "Coin")
        {
            se.SePlay("coin");
            col.gameObject.GetComponent <SphereCollider>().enabled = false;
            Destroy(col.gameObject);
            HitItem();
        }
        if (col.gameObject.tag == "Block")
        {
            if (col.gameObject.name == "startBlock(Clone)")
            {
                oldBlock = col.gameObject;
            }

            oldBlock2 = oldBlock;
            oldBlock  = col.gameObject;
        }
        if (col.gameObject.name == "GameOverLine(Clone)")
        {
            state = PLAYER_STATE.RECOVERY;
            transform.position = new Vector3(oldBlock2.transform.position.x, oldBlock2.transform.position.y + 1.0f, oldBlock2.transform.position.z);
            speed = 1.0f;
        }
    }
    // Use this for initialization
    void Start()
    {
        PlayerLife.Health = 100;
        PlayerLife.Armour = 0;
        PlayerLife.Mana = 0;

        PlayerState = PLAYER_STATE.Idle;
    }
Example #33
0
 private void CmdChangeState(PLAYER_STATE state)
 {
     setPlayerState (state);
 }
Example #34
0
 private void btnPlayPause_Click(object sender, RoutedEventArgs e)
 {
     if (mediaType == MEDIA_TYPE.FILE)
     {
         if (State == PLAYER_STATE.STATE_PLAYING)
         {
             dxPlayer.Pause();
             State = PLAYER_STATE.STATE_PAUSED;
         }
         else if (State == PLAYER_STATE.STATE_PAUSED)
         {
             dxPlayer.Pause();
             State = PLAYER_STATE.STATE_PLAYING;
         }
         else if (State == PLAYER_STATE.STATE_STOPPED)
         {
             if (strURI != null)
                 OpenFile(strURI);
         }
     }
     else if (mediaType == MEDIA_TYPE.NETWORK)
     {
         if (State == PLAYER_STATE.STATE_STOPPED)
         {
             if (strURI != null)
                 Connect(strURI, streamType);
         }
     }
     else if (mediaType == MEDIA_TYPE.STREAMING)
     {
         if (State == PLAYER_STATE.STATE_STOPPED)
             if (serverSession != null && strURI != null)
                 OpenStreamingSession(serverSession, strURI, streamType, serverPort);
     }
 }
Example #35
0
 private void checkClimb( )
 {
     if (_hit_object_tag != "CanClimb") {
         gameObject.GetComponent<Rigidbody> ().useGravity = true;
         _climbed_high = false;
         _climbed_normal = false;
         return;
     }
     if (_hit_object.transform.localScale.y < 2 && !_climbed_normal) {
         _player_state = PLAYER_STATE.PLAYER_STATE_CLIMB;
         gameObject.GetComponent<Rigidbody> ().useGravity = false;
     } else if (_hit_object.transform.localScale.y > 2 && !_climbed_high) {
         _player_state = PLAYER_STATE.PLAYER_STATE_CLIMB_HIGH;
         gameObject.GetComponent<Rigidbody> ().useGravity = false;
     }
 }
Example #36
0
    public void setPlayerState(PLAYER_STATE pState)
    {
        if (isServer){
          PlayerState = pState;
          GameObject.Find ("GameManager").GetComponent<GameManager> ().checkPlayerStates ();
          if (pState == PLAYER_STATE.VehicleSelectReady)
        RpcVehicleReady (true);
          else if (pState == PLAYER_STATE.VehicleSelect){
        RpcVehicleReady (false);
        RpcReturnToVehicleSelection ();
          }
          else if(pState == PLAYER_STATE.RaceFinished)
        setRaceTime(fRaceTime);
        }//End if(isServer)
        else
          CmdChangeState (pState);

        if(isLocalPlayer && (pState == PLAYER_STATE.SceneOutro || pState == PLAYER_STATE.SceneIntro))
          activateFader ();
    }
Example #37
0
        private void ClosePlayer()
        {
            dxPlayer.Close();
            dxPlayer.StopServer();

            sliderTimeline.IsEnabled = false;
            sliderTimeline.Value = 0;

            State = PLAYER_STATE.STATE_STOPPED;
        }
Example #38
0
    public void setPlayerState(PLAYER_STATE pState)
    {
        if (isServer){
          PlayerState = pState;
          GameObject.Find ("GameManager").GetComponent<GameManager> ().checkPlayerStates ();

          switch(pState){
          case PLAYER_STATE.VehicleSelectReady:
        RpcVehicleReady (true);
        break;
          case PLAYER_STATE.VehicleSelect:
        RpcVehicleReady (false);
        RpcReturnToVehicleSelection ();
        break;
          case PLAYER_STATE.RaceFinished:
        setRaceTime (fRaceTime);
        break;
          case PLAYER_STATE.SceneOutro:
        RpcActivateFader (Fader.FADE_STATE.FadeOut);
        break;
          case PLAYER_STATE.SceneIntro:
        RpcActivateFader (Fader.FADE_STATE.FadeIn);
        break;
          default:
        break;
          }
        //      if (pState == PLAYER_STATE.VehicleSelectReady)
        //      else if (pState == PLAYER_STATE.VehicleSelect){
        //      }
        //      else if (pState == PLAYER_STATE.RaceFinished)
        //      else if (pState == PLAYER_STATE.SceneOutro)
        //      else if (pState == PLAYER_STATE.SceneIntro)
        }//End if(isServer)
        else{
          print (isServer + " " + iPlayerNum);
          CmdChangeState (pState);
        }
        //
        //    if (pState == PLAYER_STATE.SceneOutro || pState == PLAYER_STATE.SceneIntro){
        //      if (isServer && isLocalPlayer)
        //        activateFader ();
        //      else if (isServer && !isLocalPlayer)
        //        RpcActivateFader ();
        //    }
    }
Example #39
0
        private void OpenStreamingSession(string session, string strURL, STREAM_TYPE streamType, ushort port)
        {
            ClosePlayer();

            string username = "", passwd = "", url = "";
            if (ParseURL(strURL, ref username, ref passwd, ref url) == false)
            {
                MessageBox.Show("잘못된 URL 입니다", "에러");
                return;
            }

            dxPlayer.Test(0x9635371);
            int ret = dxPlayer.OpenLiveServerSession(session, strURL, (int)streamType, 2);
            if (ret == -9)
            {
                LoginWindow login = new LoginWindow();
                login.Owner = this;
                if (login.ShowDialog() == true)
                {
                    strURL = "rtsp://" + login.txtBoxID.Text + ":" + login.passwd.Password + "@" + url;
                    OpenStreamingSession(session, strURL, streamType, port);
                }
                return;
            }

            if (ret < 0)
            {
                MessageBox.Show(strURL + " 을(를) 열지 못했습니다", "에러");
                return;
            }

            ret = dxPlayer.Play(0.0);
            if (ret < 0)
            {
                ClosePlayer();
                MessageBox.Show(strURL + " 을(를) 열지 못했습니다", "에러");
                return;
            }

            ret = dxPlayer.StartServer(port);
            if (ret < 0)
            {
                ClosePlayer();
                MessageBox.Show(strURL + "서버를 시작하지 못했습니다", "에러");
                return;
            }

            sliderTimeline.Value = 0;
            sliderTimeline.IsEnabled = false;

            mediaInfo.Reset();
            this.mediaType = MEDIA_TYPE.STREAMING;
            this.strURI = strURL;
            this.serverSession = session;
            this.streamType = streamType;

            State = PLAYER_STATE.STATE_PLAYING;

            AddRecentMediaList(new MediaPlayInfo(session, strURI, streamType, port));
        }
Example #40
0
 private void _playback_start() {
     _player_state = PLAYER_STATE.PLAYING;
     btn_play.Background = FindResource("Pause") as DrawingBrush;
     ml_main.Volume = sl_volume.Value;
     ml_main.Play();
     if (main_context_view_always_on_top_when_playing.IsChecked) {
         this.Topmost = true;
     }
     if (border_media_element.Background == _ml_main_background) {
         border_media_element.Background = new SolidColorBrush(Colors.Black);
     }
     this.TaskbarItemInfo.ProgressState = TaskbarItemProgressState.Normal;
 }
Example #41
0
 private void _pause() {
     btn_play.Background = FindResource("Play_fwd") as DrawingBrush;
     ml_main.Pause();
     if (main_context_view_always_on_top_when_playing.IsChecked) {
         this.Topmost = false;
     }
     this.TaskbarItemInfo.ProgressState = TaskbarItemProgressState.Paused;
     _player_state = PLAYER_STATE.PAUSED;
 }
Example #42
0
        private void OpenFile(string filepath)
        {
            ClosePlayer();

            dxPlayer.SetTimer(1);
            int ret = dxPlayer.OpenFile(filepath);
            if (ret < 0)
            {
                MessageBox.Show(filepath + " 을(를) 열지 못했습니다", "에러");
                return;
            }

            if (ParseMediaInfo(dxPlayer.GetStringInfo("mediainfo")) == true)
            {
                sliderTimeline.Minimum = 0;
                sliderTimeline.Maximum = mediaInfo.totalTime;
                sliderTimeline.IsEnabled = true;

                if (mediaInfo.startTime != 0 && mediaInfo.endTime != 0)
                {
                    startTime = new DateTime(1970, 1, 1).AddMilliseconds(mediaInfo.startTime);
                    startTime += TimeZone.CurrentTimeZone.GetUtcOffset(startTime);

                    endTime = new DateTime(1970, 1, 1).AddMilliseconds(mediaInfo.endTime);
                    endTime += TimeZone.CurrentTimeZone.GetUtcOffset(endTime);
                }
                else
                {
                    startTime = DateTime.MinValue;
                    endTime = DateTime.MinValue;
                }
            }

            ret = dxPlayer.Play(0.0);
            if (ret < 0)
            {
                ClosePlayer();
                MessageBox.Show(filepath + " 을(를) 열지 못했습니다", "에러");
                return;
            }

            mediaType = MEDIA_TYPE.FILE;
            strURI = filepath;
            State = PLAYER_STATE.STATE_PLAYING;

            AddRecentMediaList(new MediaPlayInfo(MEDIA_TYPE.FILE, strURI, STREAM_TYPE.TCP));
        }
Example #43
0
    private void move( )
    {
        Vector3 rayhit_pos = _operation.getHitRaycastPos( );
        if ( rayhit_pos != new Vector3( ) ) {
            _target_pos = new Vector3 ( rayhit_pos.x, transform.position.y, rayhit_pos.z );
            _walk_speed = Vector3.Distance( _target_pos, transform.position ) / ( _move_max_time * 60 ) ;
            _check_first_touch++;
        } else {
            _check_first_touch = 0;
        }

        if ( _walk_speed > WalkMaxSpeed ) {
            _walk_speed = WalkMaxSpeed;
        }
        if ( _walk_speed < WalkMinSpeed ) {
            _walk_speed = WalkMinSpeed;
        }
        if ( _target_pos != new Vector3( ) ) {
            moveToTarget ( _target_pos, _walk_speed );
            _player_state = PLAYER_STATE.PLAYER_STATE_RUN;
            _move_time++;
            setPoint( _target_pos );
        } else {
            _player_state = PLAYER_STATE.PLAYER_STATE_STAY;
            deletePoint( );
        }
        Vector3 diff_pos = transform.position - _target_pos;
        diff_pos.y = 0;
        if ( diff_pos.magnitude < POS_DIFF  ) {
            _move_time = 0;
            _operation.resetTargetPos ( );
            _target_pos = new Vector3( );
            _player_state = PLAYER_STATE.PLAYER_STATE_STAY;
        }
    }
Example #44
0
        private void _init_rest() {
            lbl_title.Content = lbl_title.Content as string + " v" + GetRunningVersion();

			_is_expanded = main_context_view_expanded.IsChecked;
			_is_fullscreen = false;

            _player_state = PLAYER_STATE.NOT_LOADED;
            _progress_state = DURATION_LABEL.ELAPSED;
            _current_media_type = MEDIA_TYPE.VIDEO;

            _ml_main_background = border_media_element.Background;

            _resize_mode_default = this.ResizeMode;

            _temp_position = TimeSpan.MinValue;

            _playlist_history = new Stack<MyMediaFile>(100);


            _timer = new DispatcherTimer();
            _timer.Interval = new TimeSpan(0, 0, 1);
            _timer.Tick += new EventHandler((sender, e) => {
                if (!_is_slider_dragging && _player_state == PLAYER_STATE.PLAYING) {
                    sl_progress.Value = ml_main.Position.TotalSeconds;
                    this.TaskbarItemInfo.ProgressValue = ml_main.NaturalDuration.HasTimeSpan ? sl_progress.Value / ml_main.NaturalDuration.TimeSpan.TotalSeconds : 0;
                }
            });
            _timer.Start();

            _components_visible_timer = new DispatcherTimer();
            _components_visible_timer.Interval = new TimeSpan(0, 0, CONSTANT_HIDE_COMPONENTS_DELAY);
            _components_visible_timer.Tick += new EventHandler((sender, e) => {
				if (_is_expanded || _is_fullscreen && _player_state == PLAYER_STATE.PLAYING && !main_context.IsOpen) {
                    _components_state(Visibility.Hidden);
                }
            });
            _components_visible_timer.Start();

            _timer_dragmove = new DispatcherTimer();
            _timer_dragmove.Interval = new TimeSpan(0, 0, 0, 0, DRAGMOVE_TIME_MS);
            _timer_dragmove.Tick += new EventHandler((t_sender, t_e) => {
                if (Mouse.LeftButton == MouseButtonState.Pressed) {
                    DragMove();
                }
                _timer_dragmove.Stop();
            });

            /* Subscribe to custome eventhandler for external application launch */
            App.ExternelApplicationLauncy += mainwindow_root_loaded;
        }
Example #45
0
    // Update is called once per frame
    void Update()
    {
        updateGauge ();
        setRunEffect ( );
        setAnimation ( );
        checkClimb ( );

        if ( _player_state == PLAYER_STATE.PLAYER_STATE_RUN ||
            _player_state == PLAYER_STATE.PLAYER_STATE_STAY ) {
            move ();
            _last_ground_pos = transform.position;
        }
        if ( _player_state == PLAYER_STATE.PLAYER_STATE_CLIMB ||
            _player_state == PLAYER_STATE.PLAYER_STATE_CLIMB_HIGH ) {
            climb ();
        }
        AnimatorStateInfo state = _animator.GetCurrentAnimatorStateInfo( 0 );
        if ( _gauge <= 0 ) {
            _player_state = PLAYER_STATE.PLAYER_STATE_DEAD;
        }
        if ( _clear ) {
            _player_state = PLAYER_STATE.PLAYER_STATE_CLEAR;
        }
        if ( _clear || _gauge <= 0 ) {
            _game_end_time++;
        }
    }
Example #46
0
        private void _stop() {
            btn_play.Background = FindResource("Play_fwd") as DrawingBrush;
			if (_is_fullscreen) {
                _fullwindow_toggle();
            }
            ml_main.Stop();
            ml_main.Source = null;
            border_media_element.Background = _ml_main_background;
            if (main_context_view_always_on_top_when_playing.IsChecked) {
                this.Topmost = false;
            }
            this.TaskbarItemInfo.ProgressState = TaskbarItemProgressState.Indeterminate;
            _player_state = PLAYER_STATE.STOPPED;
        }
Example #47
0
 public void setPlayerState( PLAYER_STATE state )
 {
     _player_state = state;
 }
Example #48
0
    private void climb( )
    {
        if ( transform.position.y > ( _hit_object.transform.position.y +  ( _hit_object.transform.localScale.y ) ) ) {
            if ( _player_state == PLAYER_STATE.PLAYER_STATE_CLIMB ) {
                _climbed_normal = true;
            }
            if ( _player_state == PLAYER_STATE.PLAYER_STATE_CLIMB_HIGH ) {
                _climbed_high = true;
            }
            gameObject.GetComponent<Rigidbody> ().useGravity = true;
            _player_state = PLAYER_STATE.PLAYER_STATE_STAY;

        }
        float move_y = ( ( _hit_object.transform.position.y + _hit_object.transform.localScale.y ) - ( _last_ground_pos.y - transform.localScale.y  ) ) / 100;
        move_y *= clim_speed;
        Vector3 pos = _hit_object.transform.position - gameObject.transform.position;
        pos.Normalize ();
        pos *= 0.03f;
        pos.y = move_y;
        pos += transform.position;
        transform.position = pos;
    }
Example #49
0
File: player.cs Project: soimar/uni
	// Update is called once per frame
	void Update () {
	
		//캐릭터 이동
		
		if (Input.GetKey(KeyCode.LeftArrow))
		{
			if (playerState != PLAYER_STATE.WALK)
			{
				ani.SetBool("walk",true);
				playerState = PLAYER_STATE.WALK;
			}
			
			DistanceJoint2D joint = GetComponent<DistanceJoint2D>();			
			if (!joint.enabled)
			{
				transform.rotation = Quaternion.Euler( new Vector3(0,0,90));
				transform.Translate(Vector3.up * 15 * Time.deltaTime);
				//rigidbody2D.AddForce( new Vector3(1,0,0) * -150 * Time.deltaTime );
			}
			else
			{
				transform.position += new Vector3(1,0,0) * -15 * Time.deltaTime;

				Vector2 dir = joint.connectedBody.position - new Vector2(transform.position.x,
					transform.position.y);
				dir.Normalize();
				transform.rotation = Quaternion.FromToRotation(new Vector3(0,1,0), 
					new Vector3(dir.x, dir.y, 0));				
			}
			
		}
		if(Input.GetKey(KeyCode.RightArrow))
		{
			if (playerState != PLAYER_STATE.WALK)
			{
				
				ani.SetBool("walk",true);
				playerState = PLAYER_STATE.WALK;
			}
			
			DistanceJoint2D joint = GetComponent<DistanceJoint2D>();
			if (!joint.enabled)
			{
				transform.rotation = Quaternion.Euler( new Vector3(0,0,270));
				transform.Translate(Vector3.up * 15 * Time.deltaTime);
				//rigidbody2D.AddForce( new Vector3(1,0,0) * 150 * Time.deltaTime );
			}
			else
			{
				//transform.Translate(new Vector3(1,0,0) * 15 * Time.deltaTime);
				//rigidbody2D.AddForce( new Vector3(1,0,0) * 150 * Time.deltaTime );
				
				transform.position += new Vector3(1,0,0) * 15 * Time.deltaTime;

				Vector2 dir = joint.connectedBody.position - new Vector2(transform.position.x,
					transform.position.y);
				dir.Normalize();
				transform.rotation = Quaternion.FromToRotation(new Vector3(0,1,0), 
					new Vector3(dir.x, dir.y, 0));				
				

			}
		}
		
		if(Input.GetKey(KeyCode.UpArrow))
		{
			if (playerState != PLAYER_STATE.WALK)
			{
				
				ani.SetBool("walk",true);
				playerState = PLAYER_STATE.WALK;
			}
			
			DistanceJoint2D joint = GetComponent<DistanceJoint2D>();
			if (!joint.enabled)
			{
				transform.rotation = Quaternion.Euler( new Vector3(0,0,360));
				transform.Translate(Vector3.up * 15 * Time.deltaTime);
			}
			else
			{
				transform.position += new Vector3(0,1,0) * 15 * Time.deltaTime;

				Vector2 dir = joint.connectedBody.position - new Vector2(transform.position.x,
					transform.position.y);
				dir.Normalize();
				transform.rotation = Quaternion.FromToRotation(new Vector3(0,1,0), 
					new Vector3(dir.x, dir.y, 0));				
		

			}
			
			
		}
		if(Input.GetKey(KeyCode.DownArrow))
		{
			if (playerState != PLAYER_STATE.WALK)
			{
				ani.SetBool("walk",true);
				playerState = PLAYER_STATE.WALK;
			}
			
			DistanceJoint2D joint = GetComponent<DistanceJoint2D>();
			if (!joint.enabled)
			{
				transform.rotation = Quaternion.Euler( new Vector3(0,0,180));
				transform.Translate(Vector3.down * -15 * Time.deltaTime);
			}
			else
			{
				//transform.Translate(Vector3.down * 15 * Time.deltaTime);
				transform.position += new Vector3(0,1,0) * -15 * Time.deltaTime;

				Vector2 dir = joint.connectedBody.position - new Vector2(transform.position.x,
					transform.position.y);
				dir.Normalize();
				transform.rotation = Quaternion.FromToRotation(new Vector3(0,1,0), 
					new Vector3(dir.x, dir.y, 0));				
		

			}
		}
		
		
		// push
		
		if(Input.GetKey(KeyCode.Z))
		{
			ani.SetBool("push",true);
			
			if (playerState != PLAYER_STATE.PUSH)
			{
				playerState = PLAYER_STATE.PUSH;
			}
			
			DistanceJoint2D joint = GetComponent<DistanceJoint2D>();
			if (joint.enabled)
			{
				Vector2 length = joint.connectedBody.position - new Vector2(transform.position.x, transform.position.y);
				if (5 < length.magnitude)
					joint.enabled = false;				
			}

			//transform.rotation = Quaternion.Euler( new Vector3(0,0,180));
		}
		
		
		//shoot
		
		if(Input.GetKeyDown(KeyCode.X))
		{
			ani.SetTrigger("shoot");
			if (item == true)
			{
				ani.SetTrigger("shoot");
				coll_stone = false;
				item_stone.transform.position = transform.position;
				//item_stone.gameObject.SetActive(true);
							
				//Vector3 v = new Vector3(transform.position.x+2, transform.position.y+3, transform.position.z); 
				Vector3 dir = Quaternion.Euler(transform.rotation.eulerAngles) * new Vector3(0,1,0);
				Vector3 dir_clone = Quaternion.Euler(0,0,-45) * dir;
				
				GameObject clone = (GameObject)Instantiate(stone_prefab, dir_clone*3.5f + transform.position, Quaternion.Euler(0,0,0));
							
				dir.Normalize();			
				clone.SendMessage("Shoot", dir);
				StartCoroutine("Wait2", 3);
			}			
			
		}
		
		if(Input.GetKeyUp(KeyCode.X))
		{
			playerState = PLAYER_STATE.NORMAL;
		}
		
	
		//아이템 장착/해제 
		
		if(Input.GetKeyDown(KeyCode.Space))
		{	
			if(item == false && coll_stone == true)
			{
				ani.SetBool("item", true);
				ani.SetBool("normal",false);
					
				StartCoroutine("Wait2", 1);
					
				item = true;
				GUI_stone.gameObject.SetActive(true);
				item_stone.gameObject.SetActive(false);
				
			}
			else if(item == true)
			{
				print ("item release");
				
				ani.SetBool("item",false);
				ani.SetBool("normal",true);
				
				item = false;
				GUI_stone.gameObject.SetActive(false);
				item_stone.gameObject.SetActive(true);
				
				item_stone.transform.position = transform.position;
				
				coll_stone = false;
				
				
			}			
		}
		
		
		
		//move KeyUp
		
		if(Input.GetKeyUp(KeyCode.UpArrow) ||
		   Input.GetKeyUp(KeyCode.DownArrow) ||
		   Input.GetKeyUp(KeyCode.RightArrow) ||
		   Input.GetKeyUp(KeyCode.LeftArrow))
		{
			if(!Input.GetKey(KeyCode.UpArrow) &&
			   !Input.GetKey(KeyCode.DownArrow) &&
			   !Input.GetKey(KeyCode.RightArrow) &&
			   !Input.GetKey(KeyCode.LeftArrow))
			{
				ani.SetBool("walk",false);
				
				if (playerState == PLAYER_STATE.WALK)
				{
					//walk = false;
					playerState = PLAYER_STATE.NORMAL;
				}
			}
				
		}
		
		if (Input.GetKeyUp(KeyCode.Z))
		{
			ani.SetBool("push",false);
			
			if(playerState != PLAYER_STATE.NORMAL)
			{
				DistanceJoint2D joint = GetComponent<DistanceJoint2D>();
				joint.enabled = false;
				
				if (joint.connectedBody)
				{
					joint.connectedBody.rigidbody2D.mass = 2000;
				}
			
				playerState = PLAYER_STATE.NORMAL;
			}
			/*
			else if(playerState == PLAYER_STATE.PUSH)
			{
				ani.SetTrigger("normal");
				playerState = PLAYER_STATE.NORMAL;
			}
/**/			
		}
	
				
						
	}