Exemplo n.º 1
0
    void OnCollisionEnter(Collision col)
    {
        Vector3    pos = col.contacts [0].point;
        GameObject es  = (GameObject)GameObject.Instantiate(echoSphere, pos, Quaternion.identity);

        //float tauntRadius = tauntRadiusMul * Mathf.Abs (col.impulse.magnitude / rb.mass);
        //float tauntRadius = tauntRadiusMul * col.relativeVelocity.magnitude;

        float tauntRadius = tauntRadiusMul * Mathf.Max(Mathf.Abs(Vector3.Dot(col.contacts[0].normal, col.relativeVelocity)), Mathf.Abs(Vector3.Dot(col.impulse.normalized, col.relativeVelocity)));

        es.transform.localScale = Vector3.one * tauntRadius;
        EchoSphere es1 = es.GetComponent <EchoSphere> ();

        es1.SetMaxSize(tauntRadius);
        es1.Start();
        es1.ShowTap(pos, Color.red);
        Collider[] enemies = Physics.OverlapSphere(pos, tauntRadius, enemyMask, QueryTriggerInteraction.Ignore);

        foreach (Collider c in enemies)
        {
            GuardAI ai = FindAI(c);
            if (ai != null && ai.searching < 2)
            {
                ai.TauntPos(pos, true, 1);
            }
        }
        GuardAI ai2 = FindAI(col.collider);

        if (ai2 != null)
        {
            if (col.impulse.magnitude > 10 && pos.y - ai2.myTrans.position.y > 0.5f && Vector3.Distance(pos, ai2.myTrans.position + Vector3.up) <= 1.2f)
            {
                ai2.ctrl.AddBuff(BuffIndex.stun, 1);
            }
            else
            {
                ai2.TauntPos(pos, true, 3);
            }
        }
        if (Vector3.Distance(pos, nodes [nodes.Count - 1]) > 0.1f)
        {
            nodes.Add(pos);
            while (nodes.Count > 2)
            {
                nodes.RemoveAt(0);
            }
        }

        CurveCaster.singleton.StopAim(gameObject);
    }
Exemplo n.º 2
0
    void Start()
    {
        _spheres = new List <EchoSphere>();

        for (int i = 0; i < SphereCount; i++)
        {
            EchoSphere es = new EchoSphere {
                EchoMaterial    = GetComponent <Renderer>().material,
                EchoColor       = Color.white,
                SphereMaxRadius = SphereMaxRadius,
                FadeDelay       = FadeDelay,
                FadeRate        = FadeRate,
                EchoSpeed       = EchoSpeed,
                SphereIndex     = i
            };
            Spheres.Add(es);
        }

        _currentSphere = 0;
    }