Пример #1
0
        static void Main(string[] args)
        {
            SpellsBook book = new SpellsBook();

            book.AddSpell(new SpellOne());
            book.AddSpell(new SpellOne());

            Wizard gandalf = new Wizard("Gandalf");

            gandalf.AddItem(book);

            Dwarf gimli = new Dwarf("Gimli");

            Console.WriteLine($"Gimli has ❤️ {gimli.Health}");
            Console.WriteLine($"Gandalf attacks Gimli with ⚔️ {gandalf.AttackValue}");

            gimli.ReceiveAttack(gandalf.AttackValue);

            Console.WriteLine($"Gimli has ❤️ {gimli.Health}");

            gimli.Cure();

            Console.WriteLine($"Someone cured Gimli. Gimli now has ❤️ {gimli.Health}");

            DarkArcher darkArcher = new DarkArcher("Orc Commander");

            darkArcher.Pv = 5;
            DarkBow darkBow = new DarkBow();

            darkArcher.AddItem(darkBow);
            darkArcher.ReceiveAttack(gimli.AttackValue);
            gimli.MorePv(darkArcher.ChechHealth());
        }
    private void Arrow()
    {
        GameObject darkBow       = ObjectPooler.instance.GetDanmaku(darkBowIndex);
        DarkBow    darkBowScript = darkBow.GetComponent <DarkBow>();

        darkBowScript.SetOwner(gameObject);
        darkBow.transform.position = new Vector3(transform.position.x + 1.5f, transform.position.y + Random.Range(-1f, 1f), 0f);
        darkBow.SetActive(true);
        StartCoroutine(darkBowScript.AutoChargeAndFire());
    }
    public void shopFilter(string filterType)
    {
        if (filterType == "AllItems")
        {
            GlassBow.SetActive(true);
            WolfBlade.SetActive(true);
            StoneBlade.SetActive(true);
            BattleAxe.SetActive(true);
            DarkBow.SetActive(true);

            KnightHelmet.SetActive(true);
            VikingHelmet.SetActive(true);
            ThiefArmor.SetActive(true);
            ThiefHood.SetActive(true);
            KnightArmor.SetActive(true);
            ThiefBoots.SetActive(true);
            CommonBoots.SetActive(true);
        }

        else if (filterType == "WeaponsOnly")
        {
            GlassBow.SetActive(true);
            WolfBlade.SetActive(true);
            StoneBlade.SetActive(true);
            BattleAxe.SetActive(true);
            DarkBow.SetActive(true);

            KnightHelmet.SetActive(false);
            VikingHelmet.SetActive(false);
            ThiefArmor.SetActive(false);
            ThiefHood.SetActive(false);
            KnightArmor.SetActive(false);
            ThiefBoots.SetActive(false);
            CommonBoots.SetActive(false);
        }

        else if (filterType == "ArmorOnly")
        {
            GlassBow.SetActive(false);
            WolfBlade.SetActive(false);
            StoneBlade.SetActive(false);
            BattleAxe.SetActive(false);
            DarkBow.SetActive(false);

            KnightHelmet.SetActive(true);
            VikingHelmet.SetActive(true);
            ThiefArmor.SetActive(true);
            ThiefHood.SetActive(true);
            KnightArmor.SetActive(true);
            ThiefBoots.SetActive(true);
            CommonBoots.SetActive(true);
        }
    }
    public void changeFilter(string filterType)
    {
        if (filterType == "AllItems")
        {
            BattleAxe.SetActive(true);
            DarkBow.SetActive(true);
            SkullAxe.SetActive(true);
            Dagger.SetActive(true);

            KnightHelmet.SetActive(true);
            VikingHelmet.SetActive(true);
            ThiefHood.SetActive(true);
            KnightArmor.SetActive(true);
            VikingArmor.SetActive(true);
            ThiefBoots.SetActive(true);
        }

        else if (filterType == "WeaponsOnly")
        {
            BattleAxe.SetActive(true);
            DarkBow.SetActive(true);
            SkullAxe.SetActive(true);
            Dagger.SetActive(true);

            KnightHelmet.SetActive(false);
            VikingHelmet.SetActive(false);
            ThiefHood.SetActive(false);
            KnightArmor.SetActive(false);
            VikingArmor.SetActive(false);
            ThiefBoots.SetActive(false);
        }

        else if (filterType == "ArmorOnly")
        {
            BattleAxe.SetActive(false);
            DarkBow.SetActive(false);
            SkullAxe.SetActive(false);
            Dagger.SetActive(false);

            KnightHelmet.SetActive(true);
            VikingHelmet.SetActive(true);
            ThiefHood.SetActive(true);
            KnightArmor.SetActive(true);
            VikingArmor.SetActive(true);
            ThiefBoots.SetActive(true);
        }
    }
    private IEnumerator ArcherStorm()
    {
        // Set up
        const int NUM_BOWS = 28;

        Vector3[] positions = new Vector3[NUM_BOWS];
        // calculate position based on number of bows
        for (int x = 0; x < NUM_BOWS; x++)
        {
            // find y position
            float yLevel = Mathf.FloorToInt(x / 2) - (NUM_BOWS / 4f) + .5f;
            float height = yLevel * 0.75f;
            // give x position based on x
            if (x % 4 == 0)
            {
                positions[x] = new Vector3(-7f, height, 0f);
            }
            else if (x % 4 == 1)
            {
                positions[x] = new Vector3(7f, height, 0f);
            }
            else if (x % 4 == 2)
            {
                positions[x] = new Vector3(-6.5f, height, 0f);
            }
            else if (x % 4 == 3)
            {
                positions[x] = new Vector3(6.5f, height, 0f);
            }
        }

        DarkBow[] bows = new DarkBow[NUM_BOWS];
        for (int x = 0; x < NUM_BOWS; x++)
        {
            GameObject bow = ObjectPooler.instance.GetDanmaku(darkBowIndex);
            if (bow == null)
            {
                Debug.LogError("Missing bow");
            }
            DarkBow bowScript = bow.GetComponent <DarkBow>();
            if (bowScript != null)
            {
                bows[x] = bowScript;
            }
            else
            {
                Debug.LogError("No DarkBow script.");
            }
            bowScript.SetOwner(gameObject);
            bow.transform.position = positions[x];
            if (bow.transform.position.x > 0)
            {
                bow.transform.rotation = Quaternion.Euler(0f, 0f, 180f);
            }
            else
            {
                bow.transform.rotation = Quaternion.Euler(0f, 0f, 0f);
            }
            bow.SetActive(true);
        }

        // Attack portion
        const float DURATION = 600f;
        const float COOLDOWN = 0.5f;

        for (int x = 0; x < DURATION / COOLDOWN; x++)
        {
            int  randIndex;
            int  attemptLimit = NUM_BOWS;
            bool attacked     = false;
            do
            {
                randIndex = Random.Range(0, NUM_BOWS);
                if (!bows[randIndex].IsBusy())
                {
                    StartCoroutine(bows[randIndex].AutoChargeAndFire());
                    attacked = true;
                }
                attemptLimit--;
            } while (!attacked && attemptLimit > 0);
            yield return(new WaitForSeconds(0.5f));
        }

        // Cleanup
        for (int x = 0; x < NUM_BOWS; x++)
        {
            bows[x].Deactivate();
        }

        cooldownTimer = 10f;
    }