Esempio n. 1
0
    protected override void Update()
    {
        base.Update();

        shootTimer += Time.deltaTime;
        float fraction = 1.0f / attackRate;

        if (shootTimer >= fraction)
        {
            Collider2D[] hits = Physics2D.OverlapCircleAll(transform.position, detectRadius);
            foreach (var hit in hits)
            {
                Moth moth = hit.GetComponent <Moth>();
                if (moth)
                {
                    // Attack moth!
                    start = transform;
                    end   = moth.transform;

                    StartCoroutine(ShowLine(lineDelay));

                    moth.TakeDamage(damage);
                }
            }
            shootTimer = 0f;
        }
    }
    private void AlignMoths()
    {
        foreach (Transform moth in _mothParent)
        {
            Moth mothScript = moth.GetComponent <Moth>();
            foreach (Transform mothTf in moth.transform)
            {
                if (mothTf.name != "MothTrigger")
                {
                    continue;
                }
                if (mothTf.position != moth.transform.position)
                {
                    mothTf.position = moth.transform.position;
                }
            }

            SpriteRenderer mothRenderer = moth.GetComponentInChildren <SpriteRenderer>();
            switch (mothScript.Colour)
            {
            case Moth.MothColour.Blue:
                mothRenderer.color = new Color(0f, 0f, 1f);
                break;

            case Moth.MothColour.Green:
                mothRenderer.color = new Color(0f, 1f, 0f);
                break;

            case Moth.MothColour.Gold:
                mothRenderer.color = new Color(1f, 1f, 0f);
                break;
            }
        }
    }
        static void Main(string[] args)
        {
            Moth Dale = new Moth(); //Instantiating Class Moth//

            //Dale.age = 43;
            //Dale.petTotal = 12;

            int     number1     = 4;
            int     number2     = 12;
            decimal decimal1    = 1.343m;
            decimal decimal2    = 5.353m;
            string  int1        = "3";
            string  int2        = "5";
            int     mathResult3 = Dale.Addz(int1, int2);
            int     mathResult2 = Dale.Subby(decimal1, decimal2);
            int     mathResult  = Dale.Multy(number1, number2);
            int     mathResult4 = Dale.Nothing(number2);



            Console.WriteLine(mathResult);
            Console.WriteLine(mathResult4);
            Console.WriteLine(mathResult2);
            Console.WriteLine(mathResult3);

            Console.ReadLine();
        }
        static void Main(string[] args)
        {
            Moth Dale = new Moth(); //Instantiating Class Moth//

            int number1 = 4;
            int number2 = 12;

            //Passing newly created int's through the methods created on on moth class, also labeling int placements as labeled in moth class methods//
            Dale.Multy(num1: number1, num2: number2);     //Passes two ints from list
            Console.WriteLine("Enter an integar");
            int myAnswer1 = Convert.ToInt32(Console.ReadLine());

            Console.WriteLine("Enter another integar if you wish, or not, no worries.");

            if (Console.ReadLine() != "")
            {
                int myAnswer2 = Convert.ToInt32(Console.ReadLine());
                Dale.Subby(num1: myAnswer1, num2: myAnswer2);
            }
            else
            {
                Dale.Subby(num1: myAnswer1);
            }
            Console.ReadLine();
        }
        static void Main(string[] args)
        {
            //Moth Dale = new Moth(); //Instantiating Class Moth//

            Console.WriteLine("Enter an integar");
            string newString;
            double myAnswer1 = Convert.ToDouble(Console.ReadLine());
            //double mathResult = Dale.Dividing(myAnswer1, out newString );
            double mathResult = Moth.Dividing(myAnswer1, out newString);

            Console.WriteLine("Your math result is " + mathResult);
            Console.WriteLine("I want to let you know..." + newString);


            Console.ReadLine();
        }
Esempio n. 6
0
        static void Main(string[] args)
        {
            Moth Dale = new Moth(); //Instantiating Class Moth//

            //Dale.age = 43;
            //Dale.petTotal = 12;

            int number1 = 4;
            int number2 = 3;

            //Passing newly created int's through the methods created on on moth class, also labeling int placements as labeled in moth class methods//
            //Dale.Multy(num1: number1, num2: number2);     //Exercise only asking to print number without the math operation
            //Dale.Subby(num1: number1, num2: number2);     //Exercise only asking to print number without the math operation
            //Dale.Addz(num1: number1, num2: number2);      //Exercise only asking to print number without the math operation

            Dale.Nothing(num1: number2); //Printing number2, which is 3, to the screen from the nothing method it was passed through//

            Console.ReadLine();
        }
Esempio n. 7
0
    public virtual void TriggerEntered(Collider2D other)
    {
        switch (other.tag)
        {
        case "Projectile":
            ThePlayer.Die();
            ThePlayer.GetComponent <Rigidbody2D>().velocity = new Vector2(-3f, 4f);
            break;

        case "Moth":
            Moth moth = other.GetComponentInParent <Moth>();
            moth.ConsumeMoth();
            break;

        default:
            Debug.Log(other.name + " has unknown trigger tag: " + other.tag);
            break;
        }
    }
    // when button is pressed
    public void OnButtonPressed(VirtualButtonBehaviour vButt2)
    {
        Debug.Log("SpawnNewInsect.OnButtonPressed()");
        _audioSource.Play();

        //Debug.Log("````````````````````````````````button pressed  " );
        Insect newbug;

        // Uncomment to Randomize bugs
        // if (Random.value > 0.5f)
        if (true)
        {
            newbug = new Moth();                        // create new instance of flying insect
            newbug.SpawnSelf(prefabMoth, theTrackable); // spawn prefab so we can see this new bug
        }
        else
        {
            newbug = new Gnat();                        // create new instance of flying insect
            newbug.SpawnSelf(prefabGnat, theTrackable); // spawn prefab so we can see this new bug
        }

        CreatureManager.AddCreature(newbug);            // creature manager keeps track of all bugs
    }
Esempio n. 9
0
 public MothPathHandler(Moth host)
 {
     _hostMoth = host;
 }