Exemplo n.º 1
0
    //■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
    //エフェクト生成
    //_id -> エフェクトの種類
    public void CreateEffect(int _id)
    {
        GameObject obj      = null;
        int        distance = 5 + 1;

        switch (_id)
        {
        case 0:
            //回復表示(薬草)
            manager.CreateApplyingHPText(this.gameObject, 50, 1);
            obj = Instantiate(Resources.Load("Prefabs/ItemEffect/RecoverEffect1")) as GameObject;
            obj.transform.SetParent(this.transform, false);

            //サウンドエフェクト
            soundManagerSE.TriggerSE(4);

            //プレイングバイアス
            neuralNetworkManager.ApplyPlayingBias(ValueDefinition.PLAYING_BIAS_ITEM_RECOVER_HITPOINT);
            break;

        //回復表示(食べ物)
        case 1:
            manager.CreateApplyingHPText(this.gameObject, 20, 2);
            obj = Instantiate(Resources.Load("Prefabs/ItemEffect/RecoverEffect2")) as GameObject;
            obj.transform.SetParent(this.transform, false);

            //サウンドエフェクト
            soundManagerSE.TriggerSE(4);

            //プレイングバイアス
            neuralNetworkManager.ApplyPlayingBias(ValueDefinition.PLAYING_BIAS_ITEM_RECOVER_ONAKAPOINT);
            break;

        //石を投げる
        case 2:
            obj = Instantiate(Resources.Load("Prefabs/ItemEffect/Stone")) as GameObject;

            //サウンドエフェクト
            soundManagerSE.TriggerSE(3);

            //敵がプレイヤーの正面にいるなら
            if (IsExistEnemyToForward(distance) != -1)
            {
                Enemy tmp = manager.Enemies[IsExistEnemyToForward(distance)].GetComponent <Enemy>();
                StartCoroutine(obj.GetComponent <StoneEffect>().Throw(PosX, PosY, tmp.PosX, tmp.PosY, true));
                ApplyDamageToEnemy(int.Parse(tmp.name), ValueDefinition.ITEMS_USED_TEXT[_id], 30);

                //プレイングバイアス
                neuralNetworkManager.ApplyPlayingBias(ValueDefinition.PLAYING_BIAS_ITEM_STONE_AIM_ENEMY);
            }
            else
            {
                textBox.Apply(ValueDefinition.ITEMS_USED_TEXT[_id], false);

                int toX = 0;
                int toY = 0;
                switch (Direction)
                {
                case 0:
                    for (int i = 1; i < distance; i++)
                    {
                        if (IsAnotherObject(PosX + i, PosY))
                        {
                            toX = i - 1;
                            break;
                        }

                        if (i == distance - 1)
                        {
                            toX = i;
                        }
                    }
                    break;

                case 45:
                    for (int i = 1; i < distance / 2; i++)
                    {
                        if (IsAnotherObject(PosX + i, PosY + i))
                        {
                            toX = i - 1;
                            toY = i - 1;
                            break;
                        }

                        if (fieldManager.IsRoom(PosX + i, PosY + i) == false)
                        {
                            if (i == 0)
                            {
                                toX = 0;
                                toY = 0;
                            }
                            else
                            {
                                toX = i - 1;
                                toY = i - 1;
                            }
                            break;
                        }

                        if (i == Mathf.CeilToInt(distance / 2) - 1)
                        {
                            toX = i;
                            toY = i;
                        }
                    }
                    break;

                case 90:
                    for (int i = 1; i < distance; i++)
                    {
                        if (IsAnotherObject(PosX, PosY + i))
                        {
                            toY = i - 1;
                            break;
                        }

                        if (i == distance - 1)
                        {
                            toY = i;
                        }
                    }
                    break;

                case 135:
                    for (int i = 1; i < distance / 2; i++)
                    {
                        if (IsAnotherObject(PosX - i, PosY + i))
                        {
                            toX = -(i - 1);
                            toY = i - 1;
                            break;
                        }

                        if (fieldManager.IsRoom(PosX - i, PosY + i) == false)
                        {
                            if (i == 0)
                            {
                                toX = 0;
                                toY = 0;
                            }
                            else
                            {
                                toX = -(i - 1);
                                toY = i - 1;
                            }
                            break;
                        }

                        if (i == Mathf.CeilToInt(distance / 2) - 1)
                        {
                            toX = -i;
                            toY = i;
                        }
                    }
                    break;

                case 180:
                    for (int i = 1; i < distance; i++)
                    {
                        if (IsAnotherObject(PosX - i, PosY))
                        {
                            toX = -(i - 1);
                            break;
                        }

                        if (i == distance - 1)
                        {
                            toX = -i;
                        }
                    }
                    break;

                case 225:
                    for (int i = 1; i < distance / 2; i++)
                    {
                        if (IsAnotherObject(PosX - i, PosY - i))
                        {
                            toX = -(i - 1);
                            toY = -(i - 1);
                            break;
                        }

                        if (fieldManager.IsRoom(PosX - i, PosY - i) == false)
                        {
                            if (i == 0)
                            {
                                toX = 0;
                                toY = 0;
                            }
                            else
                            {
                                toX = -(i - 1);
                                toY = -(i - 1);
                            }
                            break;
                        }

                        if (i == Mathf.CeilToInt(distance / 2) - 1)
                        {
                            toX = -i;
                            toY = -i;
                        }
                    }
                    break;

                case 270:
                    for (int i = 1; i < distance; i++)
                    {
                        if (IsAnotherObject(PosX, PosY - i))
                        {
                            toY = -(i - 1);
                            break;
                        }

                        if (i == distance - 1)
                        {
                            toY = -i;
                        }
                    }
                    break;

                case 315:
                    for (int i = 1; i < distance / 2; i++)
                    {
                        if (IsAnotherObject(PosX + i, PosY - i))
                        {
                            toX = i - 1;
                            toY = -(i - 1);
                            break;
                        }

                        if (fieldManager.IsRoom(PosX + i, PosY - i) == false)
                        {
                            if (i == 0)
                            {
                                toX = 0;
                                toY = 0;
                            }
                            else
                            {
                                toX = i - 1;
                                toY = -(i - 1);
                            }
                            break;
                        }

                        if (i == Mathf.CeilToInt(distance / 2) - 1)
                        {
                            toX = i;
                            toY = -i;
                        }
                    }
                    break;

                default:
                    break;
                }

                StartCoroutine(obj.GetComponent <StoneEffect>().Throw(PosX, PosY, PosX + toX, PosY + toY, false));
            }
            break;

        //杖
        case 3:
            obj = Instantiate(Resources.Load("Prefabs/ItemEffect/Staff")) as GameObject;
            obj.transform.position = this.transform.position;

            //サウンドエフェクト
            soundManagerSE.TriggerSE(5);

            //敵がプレイヤーの正面にいるなら敵の位置を変更する
            if (IsExistEnemyToForward(distance) != -1)
            {
                //敵の位置を変更する
                Enemy tmp = manager.Enemies[IsExistEnemyToForward(distance)].GetComponent <Enemy>();
                StartCoroutine(fieldManager.ChangeEnemiesPos(tmp));

                //敵の位置にエフェクトを発生させる
                GameObject obj2 = Instantiate(Resources.Load("Prefabs/ItemEffect/JumpAnotherPos1")) as GameObject;
                obj2.transform.position = tmp.transform.position;

                //プレイングバイアス
                neuralNetworkManager.ApplyPlayingBias(ValueDefinition.PLAYING_BIAS_ITEM_STAFF_AIM_ENEMY);
            }

            break;

        default:
            Debug.Log("エフェクト生成エラー");
            break;
        }
    }