Ejemplo n.º 1
0
    /// <summary>
    /// やられた時のエフェクトタイプをランダム生成する
    /// </summary>
    /// <param name="x">エフェクトのX座標</param>
    /// <param name="y">エフェクトのY座標</param>
    private void CreateRandomEffect(float x, float y)
    {
        StgEffectFactory factory = new StgEffectFactory();

        MhCommon.Assert(factory != null, "NormalEnemy::CreateRandomEffect() StgEffectFactory null");
        RandomIntegerSystem random = new RandomIntegerSystem();

        MhCommon.Assert(random != null, "NormalEnemy::CreateRandomEffect() RandomIntegerSystem null");
        int value = random.Get(1, 3);

        StgEffectConstant.Type type = StgEffectConstant.Type.kExplosion;
        MhCommon.Assert((value >= 1) && (value <= 3), "NormalEnemy::CreateRandomEffect() random range failure");
        if (value == 1)
        {
            type = StgEffectConstant.Type.kExplosion;
        }
        else if (value == 2)
        {
            type = StgEffectConstant.Type.kExplosion002;
        }
        else
        {
            type = StgEffectConstant.Type.kExplosion003;
        }
        GameObject effect = factory.Create(type);

        MhCommon.Assert(effect != null, "NormalEnemy::CreateRandomEffect() effect null");
        Instantiate(effect, new Vector3(x, y, 0), Quaternion.identity);
    }
Ejemplo n.º 2
0
    /// <summary>
    /// システムの情報から現在の情報を設定
    /// </summary>
    /// <param name="touch"></param>
    protected virtual void SetCurrentInfoByTouch(Touch touch)
    {
        MhCommon.Assert(touchInfo != null, "SingleTouchActionBase::SetCurrentInfoByTouch touchInfo null");
        MhCommon.Assert(touchInfo[kCurrentFrame] != null, "SingleTouchActionBase::SetCurrentInfoByTouch touchInfo[kCurrentFrame] null");

        touchInfo[kCurrentFrame].touchId  = touch.fingerId;
        touchInfo[kCurrentFrame].position = touch.position;

        switch (touch.phase)
        {
        case TouchPhase.Began:
            touchInfo[kCurrentFrame].status = TouchInfo.TouchStatus.kBegan;
            break;

        case TouchPhase.Moved:
            touchInfo[kCurrentFrame].status = TouchInfo.TouchStatus.kMoved;
            break;

        case TouchPhase.Stationary:
            touchInfo[kCurrentFrame].status = TouchInfo.TouchStatus.kStationary;
            break;

        case TouchPhase.Ended:
            touchInfo[kCurrentFrame].status = TouchInfo.TouchStatus.kEnded;
            break;

        case TouchPhase.Canceled:
            touchInfo[kCurrentFrame].status = TouchInfo.TouchStatus.kCanceled;
            break;

        default:
            break;
        }
    }
Ejemplo n.º 3
0
    public StgEnemyFactory(GameObject player)
    {
        this.player = player;
        StgPlayer playerScript = this.player.GetComponent <StgPlayer>();

        MhCommon.Assert(playerScript != null, "StgEnemyFactory::StgEnemyFactory() playerScript null");
    }
Ejemplo n.º 4
0
 /// <summary>
 /// データのリセットを行う
 /// シーン移動などで以前のデータが残らないようにする
 /// </summary>
 void ISingleTouchActionable.Reset()
 {
     MhCommon.Assert(touchInfo != null, "SingleTouchActionPc::Reset touchInfo null");
     MhCommon.Assert(touchInfo[kCurrentFrame] != null, "SingleTouchActionPc::Reset touchInfo[kCurrentFrame] null");
     MhCommon.Assert(touchInfo[kBefore1Frame] != null, "SingleTouchActionPc::Reset touchInfo[kBefore1Frame] null");
     base.Reset();
 }
Ejemplo n.º 5
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);
 }
Ejemplo n.º 6
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;
                }
            }
        }
    }
Ejemplo n.º 7
0
 public static float Get(float maxValue, float currentValue)
 {
     MhCommon.Assert(maxValue != 0.0f, "CalcPercent::Get() maxValue 0.0f");
     MhCommon.Assert(maxValue > 0.0f, "CalcPercent::Get() maxValue=" + maxValue + " (invalid value)");
     //MhCommon.Assert(currentValue > 0.0f, "CalcPercent::Get() currentValue " + currentValue + " minus(invalid value)");
     return((currentValue * 100.0f) / maxValue);
 }
Ejemplo n.º 8
0
    public void SetPosition(Vector2 v)
    {
        Rigidbody2D rigidbody2D = GetComponent <Rigidbody2D>();

        MhCommon.Assert(rigidbody2D != null, "EnemyBase::SetPosition() rigidbody2D null");
        rigidbody2D.position = v;
    }
Ejemplo n.º 9
0
    /// <summary>
    /// 各桁が格納された配列を取得する
    /// 123ならint[] = (1,2,3)となる
    /// </summary>
    /// <param name="num">配列に格納するもととなる数値</param>
    /// <returns>各桁の数値が格納されたint配列</returns>
    protected int[] GetNumArray(int num)
    {
        int[] result = new int[kDisplaySpriteNum];
        MhCommon.Assert(result != null, "DisplayNumber002::GetNumArray array null");
        int displayNum = num;

        // 初期化
        for (int i = 0; i < kDisplaySpriteNum; ++i)
        {
            result[i] = 0;
        }
        // 負の値なら反転
        if (displayNum < 0)
        {
            displayNum *= -1;
        }
        // MinValueのときは反転できないのでMaxValueとする
        if (displayNum == System.Int32.MinValue)
        {
            displayNum = System.Int32.MaxValue;
        }

        // 配列に各桁の数値を設定
        int count = 0;

        while (displayNum > 0)
        {
            int digit = displayNum % 10;
            displayNum    = displayNum / 10;
            result[count] = digit;
            ++count;
        }
        return(result);
    }
Ejemplo n.º 10
0
 // Use this for initialization
 void Start()
 {
     SceneShare.Instance.Initialize();
     MhCommon.Print("TestSceneTask::Start() SceneShare Initialize");
     //SceneShare.Instance.GetInput
     //ShareData.Instance.
 }
Ejemplo n.º 11
0
 /// <summary>
 /// エフェクトの生成
 /// </summary>
 /// <param name="type">エフェクトの種類</param>
 /// <returns>成功ならエフェクト、失敗したらnull</returns>
 public override GameObject Create(StgEffectConstant.Type type)
 {
     if (type == StgEffectConstant.Type.kExplosion)
     {
         GameObject effect = (GameObject)Resources.Load(SceneShare.Instance.GetGameResourcePathData().Get(GameResourcePathDefine.Type.kExplosionPrefab));
         MhCommon.Assert(effect != null, "StgEffectFactory::Create() kExplosion null");
         return(effect);
     }
     else if (type == StgEffectConstant.Type.kExplosion002)
     {
         GameObject effect = (GameObject)Resources.Load(SceneShare.Instance.GetGameResourcePathData().Get(GameResourcePathDefine.Type.kExplosion002Prefab));
         MhCommon.Assert(effect != null, "StgEffectFactory::Create() kExplosion002 null");
         return(effect);
     }
     else if (type == StgEffectConstant.Type.kExplosion003)
     {
         GameObject effect = (GameObject)Resources.Load(SceneShare.Instance.GetGameResourcePathData().Get(GameResourcePathDefine.Type.kExplosion003Prefab));
         MhCommon.Assert(effect != null, "StgEffectFactory::Create() kExplosion003 null");
         return(effect);
     }
     else
     {
         // kUnknownもしくは定義されているが実装されていないtypeが指定された
         MhCommon.Assert(false, "StgEffectFactory::Create() StgEffectConstant.Type invalid type=" + type);
         return(null);
     }
 }
Ejemplo n.º 12
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))
     {
         // スコアアイテム
     }
 }
Ejemplo n.º 13
0
    /// <summary>
    /// ゲージの値にパーセンテージで設定する
    /// </summary>
    /// <param name="percent">ゲージのパーセンテージ</param>
    public void SetGaugePercent(float percent)
    {
        MhCommon.Assert(gauge != null, "CanvasImageGauge::SetGaugeRaw() gauge null");
        MhCommon.Assert((percent >= 0.0f) && (percent <= 100.0f), "CanvasImageGauge::SetGaugeRaw() value invalid(0.0f - 100.0f) over range");
        float gaugeValue = CalcPercentToValue.Get(percent, 1.0f);

        gauge.fillAmount = gaugeValue;
    }
Ejemplo n.º 14
0
 /// <summary>
 /// デバッグ用データの出力
 /// </summary>
 public virtual void Print()
 {
     MhCommon.Assert(touchInfo != null, "SingleTouchActionBase::Print touchInfo null");
     MhCommon.Assert(touchInfo[kCurrentFrame] != null, "SingleTouchActionBase::Print touchInfo[kCurrentFrame] null");
     MhCommon.Assert(touchInfo[kBefore1Frame] != null, "SingleTouchActionBase::Print touchInfo[kBefore1Frame] null");
     touchInfo[kCurrentFrame].Print();
     touchInfo[kBefore1Frame].Print();
 }
Ejemplo n.º 15
0
 /// <summary>
 /// 各値の設定(値、最大値、最小値)
 /// </summary>
 /// <param name="value">設定される値</param>
 /// <param name="max">設定される値の最大値</param>
 /// <param name="min">設定される値の最小値</param>
 public void SetValues(int value, int max, int min)
 {
     this.value = value;
     maxValue   = max;
     minValue   = min;
     MhCommon.Assert(maxValue >= minValue, "ManagedInteger::SetValues() maxValue >= minValue");
     MhCommon.Assert(minValue <= maxValue, "ManagedInteger::SetValues() minValue <= maxValue");
     Adjust();
 }
Ejemplo n.º 16
0
    /// <summary>
    /// 乱数の取得(レンジ指定)
    /// </summary>
    /// <param name="min">乱数で返される最小値</param>
    /// <param name="max">乱数で返される最大値</param>
    /// <returns>min~maxまでの整数値</returns>
    public override int Get(int min, int max)
    {
        MhCommon.Assert(random != null, "RandomIntegerSystem::Get(int min, int max) random null");
        int value = random.Next(max - min);

        value = value + min;
        MhCommon.Assert((value >= min) && (value <= max), "RandomIntegerSystem::Get value invalid=" + value);
        return(value);
    }
Ejemplo n.º 17
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;
     }
 }
Ejemplo n.º 18
0
 /// <summary>
 /// デバッグ用のデータ出力
 /// 前回のフレームからタッチ状態から異なっていたら出力
 /// </summary>
 void ISingleTouchActionable.PrintDifference()
 {
     MhCommon.Assert(touchInfo != null, "SingleTouchActionPc::PrintDifference touchInfo null");
     MhCommon.Assert(touchInfo[kCurrentFrame] != null, "SingleTouchActionPc::PrintDifference touchInfo[kCurrentFrame] null");
     MhCommon.Assert(touchInfo[kBefore1Frame] != null, "SingleTouchActionPc::PrintDifference touchInfo[kBefore1Frame] null");
     if (touchInfo[kCurrentFrame].Equals(touchInfo[kBefore1Frame]) == false)
     {
         touchInfo[kCurrentFrame].Print();
     }
 }
 public override state Update(float elapsedTime, UnitySingleTouchAction touchAction, UnitySingleTouchDragAction dragAction)
 {
     MhCommon.Assert(playerScript != null, "StgPlayerAttackPower5State::Update() playerScript null");
     // 発射位置の設定
     shoot.SetShootPosition(playerScript.GetShootPosition());
     shoot.SetShootOffset(new Vector3(0.0f, 0.0f, 0.0f));
     // 発射更新処理
     shoot.Update(elapsedTime, touchAction, dragAction);
     return(state.Power6);
 }
Ejemplo n.º 20
0
 /// <summary>
 /// タッチをし続けていて移動中か
 /// </summary>
 /// <returns>タッチをし続けていて移動中ならtrue</returns>
 bool ISingleTouchActionable.IsTouchMoved()
 {
     MhCommon.Assert(touchInfo != null, "SingleTouchActionSmartPhone::IsTouchMoved touchInfo null");
     MhCommon.Assert(touchInfo[kCurrentFrame] != null, "SingleTouchActionSmartPhone::IsTouchMoved touchInfo[kCurrentFrame] null");
     if (touchInfo[kCurrentFrame].status == TouchInfo.TouchStatus.kMoved)
     {
         return(true);
     }
     return(false);
 }
Ejemplo n.º 21
0
 /// <summary>
 /// タッチをし続けていて移動していないか
 /// </summary>
 /// <returns>タッチをし続けていて移動していないならtrue</returns>
 bool ISingleTouchActionable.IsTouchStationary()
 {
     MhCommon.Assert(touchInfo != null, "SingleTouchActionPc::IsTouchStationary touchInfo null");
     MhCommon.Assert(touchInfo[kCurrentFrame] != null, "SingleTouchActionPc::IsTouchStationary touchInfo[kCurrentFrame] null");
     if (touchInfo[kCurrentFrame].status == TouchInfo.TouchStatus.kStationary)
     {
         return(true);
     }
     return(false);
 }
Ejemplo n.º 22
0
 /// <summary>
 /// タッチがキャンセルされたか(タッチをして何らかの理由でキャンセルされた)
 /// </summary>
 /// <returns>タッチがキャンセルされたならtrue</returns>
 bool ISingleTouchDragActionable.IsDragCanceled()
 {
     MhCommon.Assert(touchInfo != null, "SingleTouchDragActionPc::IsDragCanceled touchInfo null");
     MhCommon.Assert(touchInfo[kCurrentFrame] != null, "SingleTouchDragActionPc::IsDragCanceled touchInfo[kCurrentFrame] null");
     if (touchInfo[kCurrentFrame].status == TouchInfo.TouchStatus.kCanceled)
     {
         return(true);
     }
     return(false);
 }
Ejemplo n.º 23
0
    public Vector3 GetShootPosition()
    {
        Rigidbody2D rigidbody2D = GetComponent <Rigidbody2D>();

        MhCommon.Assert(rigidbody2D != null, "StgPlayer::Attack() rigidbody2D null");
        Vector3 position = rigidbody2D.position;

        position.y += kShootOffsetY;         // 自機の本体分ずらす
        return(position);
    }
Ejemplo n.º 24
0
    /// <summary>
    /// 更新処理
    /// </summary>
    public override void Update()
    {
        base.Update();

        Rigidbody2D rigidbody2D = GetComponent <Rigidbody2D>();

        MhCommon.Assert(rigidbody2D != null, "StgItemPowerup::Update transform null");
        // 真下に進む
        rigidbody2D.velocity = new Vector2(0.0f, -0.8f);
    }
Ejemplo n.º 25
0
 /// <summary>
 /// ドラッグ中かどうか
 /// </summary>
 /// <returns>ドラッグ中ならtrue</returns>
 bool ISingleTouchDragActionable.IsDragging()
 {
     MhCommon.Assert(touchInfo != null, "SingleTouchDragActionPc::IsDragging touchInfo null");
     MhCommon.Assert(touchInfo[kCurrentFrame] != null, "SingleTouchDragActionPc::IsDragging touchInfo[kCurrentFrame] null");
     TouchInfo.TouchStatus status = touchInfo[kCurrentFrame].status;
     if ((status == TouchInfo.TouchStatus.kBegan) || (status == TouchInfo.TouchStatus.kMoved) || (status == TouchInfo.TouchStatus.kStationary))
     {
         return(true);
     }
     return(false);
 }
Ejemplo n.º 26
0
    // Start is called before the first frame update
    void Start()
    {
        // HPゲージ取得
        gauge = GameObject.Find("Gauge").GetComponent <CanvasImageGauge>();
        gauge.SetGaugeRaw(1.0f);

        MhCommon.Assert(player != null, "StgPlayerHealth::Start() player null");
        playerScript = this.player.GetComponent <StgPlayer>();
        MhCommon.Assert(playerScript != null, "StgPlayerHealth::Start() playerScript null");
        playerScript.SetHealthObserver(this);
    }
Ejemplo n.º 27
0
    /// <summary>
    /// データのリセットを行う
    /// シーン移動などで以前のデータが残らないようにする
    /// </summary>
    public virtual void Reset()
    {
        MhCommon.Assert(touchInfo != null, "SingleTouchActionBase::Reset touchInfo null");
        int size = touchInfo.Length;

        for (int i = 0; i < size; ++i)
        {
            MhCommon.Assert(touchInfo[i] != null, "SingleTouchActionBase::Reset touchInfo[i] null");
            touchInfo[i].Clear();
        }
    }
Ejemplo n.º 28
0
    public override void Update()
    {
        base.Update();
        Rigidbody2D rigidbody2D = GetComponent <Rigidbody2D>();

        MhCommon.Assert(rigidbody2D != null, "DiagonalMoveEnemy::Update transform null");

        // Z軸回転するようにする
        rigidbody2D.angularVelocity = 30.0f;

        rigidbody2D.velocity = direction;
    }
Ejemplo n.º 29
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");
    }
Ejemplo n.º 30
0
    /// <summary>
    /// 更新処理
    /// </summary>
    public override void Update()
    {
        //Transform transform = GetComponent<Transform>();
        //MhCommon.Assert(transform != null, "NormalEnemy::Update transform null");
        Rigidbody2D rigidbody2D = GetComponent <Rigidbody2D>();

        MhCommon.Assert(rigidbody2D != null, "NormalEnemy::Update transform null");

        // Z軸回転するようにする
        rigidbody2D.angularVelocity = 30.0f;
        // 真下に進む
        rigidbody2D.velocity = new Vector2(0.0f, -0.5f);
    }