コード例 #1
0
ファイル: FightSystem.cs プロジェクト: mrZmitser/CatFish
    public void StartBattle(UnityCharacter enemy, UnityCharacter player, Collider2D collision)
    {
        if (FightStarted)
        {
            return;
        }
        this.FightStarted = true;
        GameObject.Find("Saving").GetComponent <SaveManager>().Save();
        message.Show("Время битвы!");
        this.satellites = player.satellites;
        satellites.Add(player);
        foreach (var satellite in this.satellites)
        {
            satellite.Character.DeathEvent += OnDeath;
        }
        this.enemies = enemy.satellites;
        enemies.Add(enemy);
        foreach (var satellite in this.enemies)
        {
            satellite.Character.DeathEvent += OnDeath;
            if (satellite.gameObject.name != enemy.gameObject.name)
            {
                satellite.transform.Find("FightZone").GetComponent <Collider2D>().enabled = false;
            }
        }
        this.collision = collision;
        this.turn      = 0;

        Battle();
    }
コード例 #2
0
    public void Cast(int power)
    {
        var item = unityInventory.transform.Find("Slot (" + active.selectedArtifactIndex.ToString() + ")").GetComponent <ItemSlotScript>();

        if (active.Character.Inventory.Artifacts[(int)active.selectedArtifactIndex].HasPower && power == 0)
        {
            message.Show("Промах!");
        }
        if (active.Character.Inventory.Artifacts[(int)active.selectedArtifactIndex].HasPower &&
            power == Math.Min((int)active.Character.Inventory.Artifacts[(int)active.selectedArtifactIndex].Power, (int)thisReceiver.MaxHp))
        {
            message.Show("Критический урон!");
        }
        uint hpBefore = thisReceiver.Hp;

        active.Character.Inventory.ActivateArtifact((int)active.selectedArtifactIndex, thisReceiver, (uint)power);
        uint hpAfter = thisReceiver.Hp;

        if (hpAfter == hpBefore && active.Character.Inventory.Artifacts[(int)active.selectedArtifactIndex].HasPower)
        {
            message.Show("Промах!");
        }
        if (hpAfter == 0 && hpBefore != 0)
        {
            message.Show("Смертельный урон!");
        }
        item.ShowDescription();
        item.ShowDescription();
    }
コード例 #3
0
    public void Add(Quest quest)
    {
        if (this.GetByTag(quest.Tag) != null)
        {
            return;
        }
        quests.Add(quest);
        message.Hide();
        if (!quest.IsFinished)
        {
            message.Show("Задание: " + quest.Description);

            ActiveQuests++;
        }
        if (demonstrator.gameObject.activeSelf)
        {
            demonstrator.Hide();
            demonstrator.Show();
        }
    }
コード例 #4
0
 private void OnTriggerEnter2D(Collider2D collision)
 {
     if (collision.gameObject.tag == "Door")
     {
         if (!collision.GetComponent <DoorScript>().isOpened)
         {
             message.Show("Нажмите E, чтобы открыть");
         }
     }
     if (collision.gameObject.tag == "PickUp" || collision.gameObject.tag == "PickUpUnique")
     {
         message.Show("Нажмите E, чтобы подобрать");
     }
     if (collision.gameObject.name == "MagicClothes")
     {
         message.Show("Нажмите E, чтобы надеть");
     }
     if (collision.gameObject.tag == "FightZone")
     {
         fightSystem.StartBattle(collision.transform.parent.GetComponent <UnityCharacter>(), this.transform.parent.GetComponent <UnityCharacter>(),
                                 collision);
     }
     if (collision.gameObject.tag == "Talkable")
     {
         message.Show("Нажмите E, чтобы поговорить");
     }
 }