Exemplo n.º 1
0
  public void Activate()
  {
      Vector2        a;
      ModifyPosition mp = new ModifyPosition();

      for (int i = 0; i < fs.enemies.Count; i++)
      {
          a = mp.Modify(enemies[i].x, enemies[i].z);
          Debug.Log("........");
          Debug.Log((int)a.x);
          Debug.Log((int)a.y);
          Debug.Log("........");
          if (type == 1)
          {
              if (a.x == 0 && a.y == 1)
              {
                  enemies[i].nowHP -= (15 * level);       //1マス前方攻撃
              }
          }
          else if (type == 2)
          {
              if (-1 <= a.x && a.x <= 1 && a.y == 1)
              {
                  enemies[i].nowHP -= (20 * level);       //1マス前方,左右斜め1マス前攻撃
              }
          }
          else if (type == 3)
          {
              if (-1 <= a.x && a.x <= 1 && -1 <= a.y && a.y <= 1)
              {
                  enemies[i].nowHP -= (25 * level);       //1マス周囲攻撃
              }
          }
          else if (type == 4)
          {
              Vector2 b = mp.WallVertical(pl.dire);
              b = mp.Modify((int)b.x, (int)b.y);
              if (a.x == 0 && a.y > 0 && a.y < b.y)
              {
                  Vector2 c;
                  bool    f = true;
                  for (int j = 0; j < fs.enemies.Count; j++)
                  {
                      c = mp.Modify(enemies[j].x, enemies[j].z);
                      if (c.x == 0 && c.y < a.y)
                      {
                          f = false;
                          break;
                      }
                  }
                  if (f)
                  {
                      enemies[i].nowHP -= (30 * level);          //前方1列攻撃
                  }
              }
          }
          else if (type == 5)
          {
              if (Floor.Map[pl.posX, pl.posZ] == 11)
              {
                  Vector2 b = mp.WallVertical(0);
                  Vector2 c = mp.WallVertical(2);
                  Vector2 d = mp.WallVertical(4);
                  Vector2 e = mp.WallVertical(6);
                  if (e.x < enemies[i].x && enemies[i].x < c.x && d.y < enemies[i].z && enemies[i].z < b.y)
                  {
                      enemies[i].nowHP -= (40 * level);         //部屋全体攻撃
                  }
              }
              else if (Floor.Map[pl.posX, pl.posZ] == 12)
              {
                  if (a.x == 0 && a.y == 1)
                  {
                      enemies[i].nowHP -= (5 * level);
                  }
              }
          }
          else if (type == 6)
          {
              int healQuantity = 20 * level;
              if ((Player.maxHP - Player.nowHP) > healQuantity)
              {
                  Player.nowHP += healQuantity;
              }
              else
              {
                  Player.nowHP = Player.maxHP;
              }
              healQuantity = 0;
          }
          Debug.Log("敵のHP↓");
          Debug.Log(enemies[i].nowHP);
      }
  }
Exemplo n.º 2
0
    // Start is called before the first frame update
    public void setting()
    {
        CardDeck = GameObject.Find("CardDeck");
        cds      = CardDeck.GetComponent <CardDeckScript>();
        mp       = new ModifyPosition();
        int RateOfNum = (int)UnityEngine.Random.Range(0, 100);
        int Num;

        if (RateOfNum < 40)
        {
            Num = 3;
        }
        else if (RateOfNum < 70)
        {
            Num = 2;
        }
        else if (RateOfNum < 90)
        {
            Num = 4;
        }
        else
        {
            Num = 1;
        }
        int RateOfType, RateOfLevel, RateOfProperty;

        for (int i = 0; i < Num; i++)
        {
            RateOfType     = (int)UnityEngine.Random.Range(0, 100);
            RateOfLevel    = (int)UnityEngine.Random.Range(0, 100);
            RateOfProperty = (int)UnityEngine.Random.Range(0, 100);
            int   type, level, property;
            int[] card = new int[3];
            //Type
            if (RateOfType < 45)
            {
                type = 1;
            }
            else if (RateOfType < 65)
            {
                type = 2;
            }
            else if (RateOfType < 75)
            {
                type = 3;
            }
            else if (RateOfType < 85)
            {
                type = 4;
            }
            else if (RateOfType < 92)
            {
                type = 5;
            }
            else
            {
                type = 6;
            }
            //Level
            if (RateOfLevel < 50)
            {
                level = 1;
            }
            else if (RateOfLevel < 80)
            {
                level = 2;
            }
            else if (RateOfLevel < 92)
            {
                level = 3;
            }
            else if (RateOfLevel < 97)
            {
                level = 4;
            }
            else
            {
                level = 5;
            }
            //Property
            if (RateOfProperty < 40)
            {
                property = 1;
            }
            else if (RateOfProperty < 55)
            {
                property = 2;
            }
            else if (RateOfProperty < 70)
            {
                property = 3;
            }
            else if (RateOfProperty < 85)
            {
                property = 4;
            }
            else
            {
                property = 5;
            }
            card[0] = type;
            card[1] = level;
            card[2] = property;
            ItemList.Add(card);
        }
        int x, z;

        for (;;)
        {
            x = UnityEngine.Random.Range(0, Floor.x);
            z = UnityEngine.Random.Range(0, Floor.z);
            if (Floor.Map[x, z] == 1)
            {
                ItemX = x;
                ItemZ = z;
                transform.position = new Vector3(x, 0f, z);
                Floor.Map[x, z]   += 30;
                break;
            }
        }
    }