예제 #1
0
 protected MainCharacter(string id, string roleType, GameObject gameObject) : base(id, gameObject)
 {
     m_input          = new CrossInput();
     m_skill          = new CharacterSkill(this);
     gameObject.layer = LayerConfig.Main;
     pack             = new MainCharacterPack(roleType, center);
 } // end MainCharacter
예제 #2
0
 private void ZoomHandle()
 {
     targetFov = Mathf.Clamp(
         value: targetFov + CrossInput.ZoomValue().Wrap(-option.MaxZoomValue, option.MaxZoomValue),
         min: option.FovClampValue.x,
         max: option.FovClampValue.y);
 }
예제 #3
0
파일: PenManager.cs 프로젝트: tokibuta/PCCA
    void Update()
    {
        return;

        var touch = CrossInput.GetAction();

        if (!penCollision && touch == CrossInput.Action.Began)
        {
            //ライン生成フラグ
            VariableHolder.Instance.CreateLineFlag = true;

            var position = CrossInput.GetPosition();
            position.z = -Camera.main.transform.position.z;
            // マウス位置座標をスクリーン座標からワールド座標に変換する
            // penTransform.position = Camera.main.ScreenToWorldPoint(position);
            penTransform1.position = Camera.main.ScreenToWorldPoint(position);


            //ペン座標を共有に保存
            VariableHolder.Instance.PenPos = penTransform1.position;

            if (!effect.isPlaying)
            {
                effect.Play();
            }
        }
        else if (!penCollision && touch == CrossInput.Action.Moved)
        {
            var position = CrossInput.GetPosition();
            position.z = -Camera.main.transform.position.z;
            // マウス位置座標をスクリーン座標からワールド座標に変換する
            penTransform.position = Camera.main.ScreenToWorldPoint(position);

            //ペン座標を共有に保存
            VariableHolder.Instance.PenPos = penTransform.position;

            if (!effect.isPlaying)
            {
                effect.Play();
            }
        }
        else if (penCollision || touch == CrossInput.Action.Ended)
        {
            VariableHolder.Instance.CreateLineFlag = false;

            penTransform1.position = new Vector3(-20, 0, 0);

            if (effect.isPlaying)
            {
                effect.Stop();
            }
        }
    }
예제 #4
0
    void Update()
    {
        if (VariableHolder.Instance.PauseLine)
        {
            return;
        }

        //ボムボタン押下時
        if (CrossPlatformInputManager.GetButtonUp("Fire2"))
        {
            //ObjectPoolのリストに乗っているオブジェクトをすべてにリサイクル処理を実施
            ObjectPool.Recycle();

            //ボムをカウント
            VariableHolder.Instance.BombCount++;

            //ゲージをすべて消費
            timeLimit = 0;
        }

        //2019/03/15追記 外部からの要因によりゲージを増減させる処理
        switch (VariableHolder.Instance.GaugeCommand)
        {
        case 0:
            //今の所何もしない
            break;

        case 1:
            //ゲージを増加
            if (timeLimit < 400)
            {
                timeLimit += timePlus;
            }
            break;

        case -1:
            //ゲージを減少
            // Debug.Log("minus");
            timeLimit -= timeMinus;
            if (timeLimit <= 0)
            {
                timeLimit = 0;
            }
            break;
        }

        //ゲージの増減
        gaugeImage.fillAmount = timeLimit / maxTimeLimit;

        // //追記20181128
        // var touch = CrossInput.GetAction();
        // var position = CrossInput.GetPosition();

        //マルチタッチに対応
        CrossInput.Data[] myTouches = CrossInput.GetData();
        if (myTouches != null)
        {
            // Touch[] myTouches = Input.touches;
            for (int i = 0; i < CrossInput.currentDataLength; i++)
            {
                Vector3 position = myTouches[i].GetPosition();
                position.z = -Camera.main.transform.position.z;

                // マウス位置座標をスクリーン座標からワールド座標に変換する
                if (!virtualPenTransform.ContainsKey(myTouches[i].GetFingerId()))
                {
                    //エフェクト生成
                    virtualPenObject[myTouches[i].GetFingerId()] = Instantiate <GameObject>(
                        VirtualPen,
                        VirtualPen.transform.position,
                        VirtualPen.transform.rotation,
                        this.transform
                        );
                    //Transformを設定
                    virtualPenTransform[myTouches[i].GetFingerId()] = virtualPenObject[myTouches[i].GetFingerId()].transform;

                    //パーティクルを設定
                    virtualPenParticle[myTouches[i].GetFingerId()] = virtualPenObject[myTouches[i].GetFingerId()].GetComponent <ParticleSystem>();
                }
                virtualPenTransform[myTouches[i].GetFingerId()].position = Camera.main.ScreenToWorldPoint(position);

                //ペンレイ
                var rayTop = new Ray2D(
                    new Vector3(
                        virtualPenTransform[myTouches[i].GetFingerId()].position.x - 0.05f,
                        virtualPenTransform[myTouches[i].GetFingerId()].position.y + 0.05f,
                        0
                        ),
                    new Vector2(0.5f, 0)
                    );
                var rayBottom = new Ray2D(
                    new Vector3(
                        virtualPenTransform[myTouches[i].GetFingerId()].position.x - 0.05f,
                        virtualPenTransform[myTouches[i].GetFingerId()].position.y - 0.05f,
                        0
                        ),
                    new Vector2(0.5f, 0)
                    );
                var rayRight = new Ray2D(
                    new Vector3(
                        virtualPenTransform[myTouches[i].GetFingerId()].position.x - 0.05f,
                        virtualPenTransform[myTouches[i].GetFingerId()].position.y - 0.05f,
                        0
                        ),
                    new Vector2(0, 0.5f)
                    );
                var rayLeft = new Ray2D(
                    new Vector3(
                        virtualPenTransform[myTouches[i].GetFingerId()].position.x + 0.05f,
                        virtualPenTransform[myTouches[i].GetFingerId()].position.y - 0.05f,
                        0
                        ),
                    new Vector2(0, 0.5f)
                    );

                // Debug.DrawRay(rayTop.origin, new Vector2(0.1f, 0), Color.red);
                // Debug.DrawRay(rayBottom.origin, new Vector2(0.1f, 0), Color.green);
                // Debug.DrawRay(rayRight.origin, new Vector2(0, 0.1f), Color.yellow);
                // Debug.DrawRay(rayLeft.origin, new Vector2(0, 0.1f), Color.blue);

                RaycastHit2D hitTop    = Physics2D.Raycast(rayTop.origin, new Vector2(0.5f, 0), 0.1f);
                RaycastHit2D hitBottom = Physics2D.Raycast(rayBottom.origin, new Vector2(0.5f, 0), 0.1f);
                RaycastHit2D hitRight  = Physics2D.Raycast(rayRight.origin, new Vector2(0, 0.5f), 0.1f);
                RaycastHit2D hitLeft   = Physics2D.Raycast(rayLeft.origin, new Vector2(0, 0.5f), 0.1f);

                if (hitTop.collider == null && hitBottom.collider == null && hitRight.collider == null && hitLeft.collider == null)
                {
                    penCollision[myTouches[i].GetFingerId()] = false;
                }
                else
                {
                    penCollision[myTouches[i].GetFingerId()] = true;
                    virtualPenTransform[myTouches[i].GetFingerId()].position = new Vector3(0, 0, 0);
                    // // Debug.Log("pne collision");
                }

                if (!penCollision[myTouches[i].GetFingerId()] && myTouches[i].GetPhase() == CrossInput.Action.Began)
                {
                    //仮想ペンエフェクト開始
                    if (!virtualPenParticle[myTouches[i].GetFingerId()].isPlaying)
                    {
                        virtualPenParticle[myTouches[i].GetFingerId()].Play();
                    }

                    // Debug.Log("id: " + myTouches[i].GetFingerId() + " : Began");

                    //コライダーを設定する
                    setInfoObject[myTouches[i].GetFingerId()] = true;

                    //ゲージを減らす
                    timeLimit -= timeMinus;
                    if (timeLimit <= 0)
                    {
                        timeLimit = 0;
                        return;
                    }

                    Init(myTouches[i].GetFingerId(), virtualPenTransform[myTouches[i].GetFingerId()].position);
                }
                else if (!penCollision[myTouches[i].GetFingerId()] && myTouches[i].GetPhase() == CrossInput.Action.Moved)
                {
                    // Debug.Log("id: " + myTouches[i].GetFingerId() + " : Moved");

                    //ペンが障害物から外に出たときにオブジェクトを作成し直すようにする
                    //beganのタイミングでbeforeActionが登録されているためエラーにはならない(理論的に);
                    if (beforeAction.ContainsKey(myTouches[i].GetFingerId()) && beforeCollision.ContainsKey(myTouches[i].GetFingerId()))
                    {
                        if (beforeAction[myTouches[i].GetFingerId()] == myTouches[i].GetPhase() && beforeCollision[myTouches[i].GetFingerId()])
                        {
                            //仮想ペンエフェクト開始
                            if (!virtualPenParticle[myTouches[i].GetFingerId()].isPlaying)
                            {
                                virtualPenParticle[myTouches[i].GetFingerId()].Play();
                            }

                            //コライダーを設定する
                            setInfoObject[myTouches[i].GetFingerId()] = true;
                            Init(myTouches[i].GetFingerId(), virtualPenTransform[myTouches[i].GetFingerId()].position);
                        }

                        //ゲージを減らす
                        timeLimit -= timeMinus;
                        if (timeLimit <= 0)
                        {
                            //仮想ペンエフェクト停止
                            if (virtualPenParticle[myTouches[i].GetFingerId()].isPlaying)
                            {
                                virtualPenParticle[myTouches[i].GetFingerId()].Stop();
                            }

                            timeLimit = 0;
                            ChangeObject(myTouches[i].GetFingerId());
                            return;
                        }

                        if (virtualPenTransform.TryGetValue(myTouches[i].GetFingerId(), out Transform transform))
                        {
                            CreateMesh(myTouches[i].GetFingerId(), transform.position);
                        }
                    }
                    else
                    {
                        return;
                    }
                }
                else if (penCollision[myTouches[i].GetFingerId()] || myTouches[i].GetPhase() == CrossInput.Action.Ended)
                {
                    //仮想ペンエフェクト停止
                    if (virtualPenParticle[myTouches[i].GetFingerId()].isPlaying)
                    {
                        virtualPenParticle[myTouches[i].GetFingerId()].Stop();
                    }

                    // Debug.Log("id: " + myTouches[i].GetFingerId() + " : Ended");
                    if (timeLimit < 400)
                    {
                        timeLimit += timePlus;
                    }
                    ChangeObject(myTouches[i].GetFingerId());
                }
                else if (myTouches[i].GetPhase() == CrossInput.Action.None)
                {
                    if (timeLimit < 400)
                    {
                        timeLimit += timePlus;
                    }
                }

                //アクション, コリジョン状況を保存(次のフレームで使用)
                beforeAction[myTouches[i].GetFingerId()]    = myTouches[i].GetPhase();
                beforeCollision[myTouches[i].GetFingerId()] = penCollision.TryGetValue(myTouches[i].GetFingerId(), out bool result) ? result : true;
            }
        }
        else
        {
            if (timeLimit < 400)
            {
                timeLimit += timePlus;
            }
        }
    }
예제 #5
0
 protected override void Awake()
 {
     base.Awake();
     CrossInput = Singleton.Instance <CrossInput>();
 }