Esempio n. 1
0
 public void SetPlayer(ref GameObject player)
 {
     MhCommon.Print("SetPlayer");
     this.player = player;
     MhCommon.Assert(this.player != null, "StgPlayerAttackNew::SetPlayer() player null");
     attackStateContext = new StgPlayerAttackStateContext(ref player);
 }
Esempio n. 2
0
    /**
     * ボタン押下イベント(引数は押されたボタン)
     */
    public void OnClick(Button self)
    {
        // どのボタンが押されたかを探す
        MhCommon.Print("DebugMenuSceneScript::OnClick");
        for (int i = 0; i < button_array.Length; ++i)
        {
            if (self.Equals(button_array[i]))
            {
                MhCommon.Print("DebugMenuSceneScript::OnClick index=" + i);
                // どのボタンが押されたかによって違う処理をする(別のシーンへ移動)
                switch (i)
                {
                case 0:
                    MhCommon.Print("DebugMenuSceneScript::OnClick GameMainScene");
                    UnityEngine.SceneManagement.SceneManager.LoadScene("GameMainScene");
                    break;

                case 1:
                    break;

                case 2:
                    //UnityEngine.SceneManagement.SceneManager.LoadScene("main_menu");
                    break;

                default:
                    break;
                }
            }
        }
    }
Esempio n. 3
0
 // Use this for initialization
 void Start()
 {
     SceneShare.Instance.Initialize();
     MhCommon.Print("TestSceneTask::Start() SceneShare Initialize");
     //SceneShare.Instance.GetInput
     //ShareData.Instance.
 }
Esempio n. 4
0
 private void OnTriggerEnter2D(Collider2D collision)
 {
     //MhCommon.Print("StgPlayer::OnTriggerEnter2D tag=" + collision.tag);
     if (collision.tag == StgGameObjectTag.ToString(StgGameObjectTag.Type.kEnemy))
     {
         MhCommon.Assert(health != null, "StgPlayer::OnTriggerEnter2D health null");
         int beforeHealth = health.GetHealth();
         health.Sub(-1);
         if (health.GetHealth() <= 0)
         {
             health.SetHealth(0);
         }
         // HP変更通知
         healthObservable.NotifyObservers(health.GetMaxHealth(), health.GetHealth(), beforeHealth - health.GetHealth());
         MhCommon.Print("StgPlayer::OnTriggerEnter2D health=" + health.GetHealth());
     }
     else if (collision.tag == StgGameObjectTag.ToString(StgGameObjectTag.Type.kItemPowerup))
     {
         // パワーアップアイテム取得処理
         Powerup();
     }
     else if (collision.tag == StgGameObjectTag.ToString(StgGameObjectTag.Type.kItemScoreup))
     {
         // スコアアイテム
     }
 }
Esempio n. 5
0
 void OnDestory()
 {
     MhCommon.Print("ScrollObjectCreater::OnDestroy");
     // 念のためにボタンを全て破棄
     for (int i = 0; i < button_array.Length; ++i)
     {
         button_array[i].onClick.RemoveAllListeners();
         button_array[i] = null;
     }
 }
Esempio n. 6
0
    // Update is called once per frame
    void Update()
    {
        UnitySingleTouchAction touchAction = SceneShare.Instance.GetInput().GetSingleTouchAction();

        touchAction.Update();
        if (touchAction.IsTouchBegan())
        {
            MhCommon.Print("TitleScene -> MainMenuScene");
            UnityEngine.SceneManagement.SceneManager.LoadScene("MainMenuScene");
        }
        //UnityEngine.SceneManagement.SceneManager.LoadScene("DebugMenuScene");
    }
Esempio n. 7
0
    // Start is called before the first frame update
    void Start()
    {
        {
            // 敵出現システムの初期化
            if (enemyRandomPopper == null)
            {
                // プレイヤーのGameObjectを取得
                GameObject player = GameObject.Find("Player");
                MhCommon.Assert(player != null, "GameMainSceneTask::Start() player null");

                enemyRandomPopper = this.gameObject.AddComponent <StgEnemyRandomPopper>() as StgEnemyRandomPopper;
                MhCommon.Assert(enemyRandomPopper != null, "GameMainSceneTask::Start() StgEnemyRandomPopper AddComponent failure");
                enemyRandomPopper.SetPlayer(player);
                MhCommon.Print("random popper created");
            }
            // ステージデータ読み込み
            {
                stgEnemyLoadResourceStageJson = new StgEnemyLoadResourceStageJson();
                stgEnemyLoadResourceStageJson.Initialize(SceneShare.Instance.GetGameResourcePathData().Get(GameResourcePathDefine.Type.kStageData01));
                //stgEnemyLoadResourceStageJson.SetResourcePath("");
                //stgEnemyLoadResourceStageJson.Load();
                stgEnemyJsonDataPopper = this.gameObject.AddComponent <StgEnemyJsonDataPopper>() as StgEnemyJsonDataPopper;
                MhCommon.Assert(stgEnemyJsonDataPopper != null, "GameMainSceneTask::Start() StgEnemyJsonDataPopper AddComponent failure");
                // プレイヤーのGameObjectを取得
                GameObject player = GameObject.Find("Player");
                MhCommon.Assert(player != null, "GameMainSceneTask::Start() player null");
                stgEnemyJsonDataPopper.SetPlayer(player);
                stgEnemyJsonDataPopper.SetJsonEnemyLaunchDatas(stgEnemyLoadResourceStageJson.Get());
            }
            {
                // パワーアップアイテムとスコアアイテムのドロップ
                StgItemMultiDropper dropper = new StgItemMultiDropper();
                dropper.SetParameter(new Vector3(0, 0, 0), StgItemConstant.Type.kPowerup);
                dropper.SetParameter(new Vector3(0.5f, 0, 0), StgItemConstant.Type.kScoreup);
                dropper.Print();
                dropper.Drop();
            }
        }
    }
Esempio n. 8
0
    // Use this for initialization
    void Start()
    {
        MhCommon.Print("DebugMenuSceneScript Start()");

        // シーンの名前表示テキスト
        string[] text_array = new string[kSceneNum]
        {
            "Game1",
            "Title",
            "MainMenu",
            "Scene03",
            "Scene04",
            "Scene05",
            "Scene06",
            "Scene07",
            "Scene08",
            "Scene09"
        };
        for (int i = 0; i < kSceneNum; ++i)
        {
            // テキストを編集
            GameObject obj = CreateScrollViewObject();
            Text       txt = obj.GetComponentInChildren <Text>();
            txt.text = text_array[i];
            // ボタンを配列に保存しておく
            Button button = obj.GetComponentInChildren <Button>();
            button_array[i] = button;
            // ボタンの押下イベントを登録(リスナーを削除してから登録)
            button.onClick.RemoveAllListeners();
            button.onClick.AddListener(() => OnClick(button));
            // ボタンの中のテキストを編集
            Text button_text = button.GetComponentInChildren <Text>();
            button_text.text = "開始";
        }
        text_array = null;
    }
Esempio n. 9
0
 public void UpdateHealth(int maxHealth, int currentHealth, int diffHealth)
 {
     // 更新
     MhCommon.Print("StgPlayerHealth::UpdateHealth() called max=" + maxHealth + " cur=" + currentHealth + " diff=" + diffHealth);
     gauge.SetGaugePercent(CalcPercent.Get((float)maxHealth, (float)currentHealth));
 }
Esempio n. 10
0
 /// <summary>
 /// 現在の状態を出力(デバッグ用)
 /// </summary>
 public void Print()
 {
     MhCommon.Print("TouchInfo::Print touchId=" + touchId +
                    " position x=" + position.x + " y=" + position.y + " z=" + position.z +
                    "status=" + GetStatusString(status));
 }
Esempio n. 11
0
 public void SetPlayer(ref GameObject player)
 {
     MhCommon.Print("SetPlayer");
     this.player = player;
     MhCommon.Assert(this.player != null, "StgPlayerAttack::SetPlayer() player null");
 }
Esempio n. 12
0
 /**
  * 現在の状態の出力
  */
 public void Print()
 {
     MhCommon.Print("TouchInfo::Print touch_id_=" + touch_id_ +
                    " position x=" + position_.x + " y=" + position_.y + " z=" + position_.z +
                    "status=" + GetStatusString(status_));
 }
Esempio n. 13
0
    // PC系のプラットフォームにTouchInfoを設定
    private void SetTouchInfoForPC()
    {
        // 前の状態を保存
        past_touch_info_.Copy(current_info_);

        TouchInfo.TouchStatus status = current_info_.status_;
        switch (status)
        {
        case TouchInfo.TouchStatus.kNone:
            // 押したりしていない状態で押されたらBeganへ移行
            if (Input.GetMouseButtonDown(0) == true)
            {
                // タッチidは0固定
                current_info_.touch_id_ = 0;
                // 位置
                current_info_.position_ = Input.mousePosition;
                current_info_.status_   = TouchInfo.TouchStatus.kBegan;
            }
            else
            {
                // デフォルトの値
                current_info_.Clear();
            }
            break;

        case TouchInfo.TouchStatus.kBegan:
            // 位置を設定
            current_info_.position_ = Input.mousePosition;
            if (Input.GetMouseButton(0) == true)
            {
                // 押しっぱなしなのでMovedかStationaryへ移行
                if (current_info_.IsPositionEquals(past_touch_info_) == true)
                {
                    current_info_.status_ = TouchInfo.TouchStatus.kStationary;
                }
                else
                {
                    current_info_.status_ = TouchInfo.TouchStatus.kMoved;
                }
            }
            else
            {
                // 持ち上げられたのでkEndedへ
                current_info_.status_ = TouchInfo.TouchStatus.kEnded;
            }
            break;

        case TouchInfo.TouchStatus.kMoved:
            current_info_.position_ = Input.mousePosition;
            if (Input.GetMouseButton(0) == false)
            {
                // 持ち上げられたのでkEndedへ
                current_info_.status_ = TouchInfo.TouchStatus.kEnded;
            }
            else
            {
                // MovedかStationaryへ移行
                if (current_info_.IsPositionEquals(past_touch_info_) == true)
                {
                    current_info_.status_ = TouchInfo.TouchStatus.kStationary;
                }
                else
                {
                    current_info_.status_ = TouchInfo.TouchStatus.kMoved;
                }
            }
            break;

        case TouchInfo.TouchStatus.kStationary:

            current_info_.position_ = Input.mousePosition;
            MhCommon.Print("x " + current_info_.position_.x + " y " + current_info_.position_.y + " z " + current_info_.position_.z);

            if (Input.GetMouseButton(0) == false)
            {
                // 持ち上げられたのでkEndedへ
                current_info_.status_ = TouchInfo.TouchStatus.kEnded;
            }
            else
            {
                // MovedかStationaryへ移行
                if (current_info_.IsPositionEquals(past_touch_info_) == true)
                {
                    current_info_.status_ = TouchInfo.TouchStatus.kStationary;
                }
                else
                {
                    current_info_.status_ = TouchInfo.TouchStatus.kMoved;
                }
            }
            break;

        case TouchInfo.TouchStatus.kEnded:
        case TouchInfo.TouchStatus.kCanceled:
            // kEndedになった瞬間に押されたらkBeganへ移行
            if (Input.GetMouseButton(0) == true)
            {
                // タッチidは0固定
                current_info_.touch_id_ = 0;
                // 位置
                current_info_.position_ = Input.mousePosition;
                current_info_.status_   = TouchInfo.TouchStatus.kBegan;
            }
            else
            {
                // デフォルト状態に戻す
                current_info_.Clear();
            }
            break;

        default:
            break;
        }
    }
Esempio n. 14
0
 /// <summary>
 /// データの中身をデバッグ出力
 /// </summary>
 public void Print()
 {
     MhCommon.Print(string.Format("StgStageJsonEnemyLaunchData::Print() enemy_type={0} time={1} x={2} y={3} z={4}",
                                  enemy_type, time, x, y, z));
     enemyItemDropDatas.Print();
 }