Beispiel #1
0
    public void Kick(Vector2 dir00)
    {
        Vector3 dir0 = dir00.ToV3AddY();

        myTrans.rotation = Quaternion.LookRotation(dir0, myTrans.up);
        Collider[]   cols  = Physics.OverlapSphere(myTrans.position, 3, GameManager.unitMask, QueryTriggerInteraction.Ignore);
        RaycastHit[] hits  = new RaycastHit[10];
        Vector3      myPos = myTrans.position;

        Debug.Log("KICK");
        foreach (Collider c in cols)
        {
            MyController mc = c.GetComponent <MyController> ();
            if (mc == null || mc == this)
            {
                continue;
            }

            Debug.Log("Passed 1");
            Vector3 dir = (mc.myTrans.position - myPos).RemoveY().normalized;
            if (Vector3.Dot(dir, dir0) < 0.5f)
            {
                continue;
            }
            Debug.Log("Passed 2");
            RaycastHit hit;
            if (c.Raycast(new Ray(myPos, dir), out hit, 1.5f))
            {
                continue;
            }

            Debug.Log("Passed 3");
            int   count      = Physics.RaycastNonAlloc(myPos, dir, hits, 1.5f, GameManager.obstacleMask, QueryTriggerInteraction.Ignore);
            float multiplier = 1;
            for (int i = 0; i < count; i++)
            {
                multiplier *= hits [i].collider.GetComponent <Obstacle> ().sightMul;
            }
            if (multiplier > 0.1f)
            {
                Debug.Log("Passed 4");
                mc.AddBuff(BuffIndex.stun, 2);
                mc.AddBuff(BuffIndex.blind, Mathf.Clamp(multiplier * UnityEngine.Random.Range(4, 6), 3, 6));
            }
        }
        CancelKick();
    }
Beispiel #2
0
    void OnCollisionEnter(Collision col)
    {
        MyController ctrl = col.collider.GetComponent <MyController> ();

        if (ctrl != null)
        {
            ctrl.AddBuff(BuffIndex.stun, 2);
            ctrl.SwitchState(StateIndex.fall);
        }
    }