Пример #1
0
    private void UpdateMask(TwoColLine colLine, Vector2 point, ref Vector2 mask)
    {
        List <TwoColManager.Col> other = colLine.ColManager.CheckCol(colLine);

        mask = Vector2.zero;

        foreach (TwoColManager.Col e in other)
        {
            if (e.col.HasType(TwoCol.ColType.COMBAT_DEF))
            {
                BatHero hero = e.col.GetComponent <BatHero>();
                if (hero)
                {
                    hero.Die();
                    die = true;
                    if (ac)
                    {
                        AudioSource.PlayClipAtPoint(ac, transform.position);
                    }
                    return;
                }
            }

            if (e.col.HasType(TwoCol.ColType.PHYSICS_DEF) && e.move.magnitude > mask.magnitude)
            {
                mask = e.move;
            }
        }
    }
Пример #2
0
    // Update is called once per frame
    void Update()
    {
        anim.Draw(this.transform.position);

        TwoCol colC = colCirc.ColManager.IsCol(colCirc, TwoCol.ColType.COMBAT_DEF);

        if (colC)
        {
            BatHero hero = colC.GetComponent <BatHero>();
            if (hero)
            {
                hero.EatMoth();
                Die();
                return;
            }
        }

        //boop.
        // Note to self: Rethink the way the hitboxes were handles by the bat (maybe make the MOTHS the ones that collide with it.
        // Seems more efficient.
        //
        // Also, instead of the random the moths currently have, maybe limit the rotation between two angles (so that the moths always go from one end of the screen to the other).

        //rot += 1.0f;

        /*if (rot >= 256.0f)
         * {
         *      rot -= 256.0f;
         * }
         * if (rot < 0.0f)
         * {
         *      rot += 256.0f;
         * }*/

        if (col.Length > 0)
        {
            Vector2 wiskR = new Vector2(Mathf.Cos(Mathf.Deg2Rad * (rot - 40.0f)) * 20.0f,
                                        Mathf.Sin(Mathf.Deg2Rad * (rot - 40.0f)) * 20.0f);
            Vector2 wiskL = new Vector2(Mathf.Cos(Mathf.Deg2Rad * (rot + 40.0f)) * 20.0f,
                                        Mathf.Sin(Mathf.Deg2Rad * (rot + 40.0f)) * 20.0f);
            Vector2 wiskM = new Vector2(Mathf.Cos(Mathf.Deg2Rad * (rot)) * 15.0f,
                                        Mathf.Sin(Mathf.Deg2Rad * (rot)) * 15.0f);
            col[0].P2 = wiskR;
            col[1].P2 = wiskL;
            col[2].P2 = wiskM;

            Vector2 leftMove = Vector2.zero, rightMove = Vector2.zero, midMove = Vector2.zero;

            foreach (TwoColManager.Col e in col[0].ColManager.CheckCol(col[0]))
            {
                rightMove += e.move;
            }
            foreach (TwoColManager.Col e in col[1].ColManager.CheckCol(col[1]))
            {
                leftMove += e.move;
            }
            foreach (TwoColManager.Col e in col[2].ColManager.CheckCol(col[2]))
            {
                midMove += e.move;
            }

            if (midMove == Vector2.zero)
            {
                deadEndTurn = 0;
            }

            if (deadEndTurn == 0)
            {
                deadEndTurn = Random.Range(0, 2);
                deadEndTurn = -1 + deadEndTurn * 2;
            }

            rot += midMove.magnitude * 2.0f * (float)deadEndTurn;
            rot -= leftMove.magnitude * 0.2f;
            rot += rightMove.magnitude * 0.2f;

            rotWander += Random.Range(-0.1f, 0.1f);
            Mathf.Clamp(rotWander, -0.25f, 0.25f);

            rot += rotWander;
        }

        this.transform.position += new Vector3(Mathf.Cos(Mathf.Deg2Rad * (rot)) * Time.deltaTime * 16.0f,
                                               Mathf.Sin(Mathf.Deg2Rad * (rot)) * Time.deltaTime * 16.0f,
                                               0.0f);
    }