Example #1
0
        private void TestAttackList(PosePlus.AniBoxCollider box)
        {
            //Debug.LogWarning("TestAttack");
            Vector3 boxpos  = aniplayer.transform.TransformPoint(box.mPosition);
            Vector3 boxsize = aniplayer.transform.TransformVector(box.mSize);

            boxsize.x = Mathf.Abs(boxsize.x);
            boxsize.y = Mathf.Abs(boxsize.y);
            boxsize.z = Mathf.Abs(boxsize.z);
            Bounds aabb = new Bounds(boxpos, boxsize);
            var    cc   = Physics.OverlapSphere(boxpos, boxsize.magnitude / 2.0f, world.layerForBeHurt.value);

            foreach (var c in cc)
            {
                if (c.transform.parent.parent == aniplayer.transform)
                {
                    continue;
                }
                if (aabb.Intersects(c.bounds))
                {
                    var pos = (aabb.center + c.bounds.center) / 2;


                    var ap = c.transform.parent.parent.GetComponent <FB.PosePlus.AniPlayer>();
                    if (attackmap.ContainsKey(ap.tagid) == false)
                    {
                        attackmap.Add(ap.tagid, pos);
                    }
                }
            }
        }
Example #2
0
        private void TestWall(float delta, PosePlus.AniBoxCollider box)
        {
            Vector3 boxpos  = transform.TransformPoint(box.mPosition);
            Vector3 boxsize = transform.TransformVector(box.mSize);

            boxsize.x = Mathf.Abs(boxsize.x);
            boxsize.y = Mathf.Abs(boxsize.y);
            boxsize.z = Mathf.Abs(boxsize.z);
            Vector3 pos = box.mPosition;
            {
                boxpos += (this.aniplayer.wantpos - transform.position);
                Bounds aabb = new Bounds(boxpos, boxsize);

                var   cc   = Physics.OverlapSphere(boxpos, boxsize.magnitude / 2.0f, world.layerForCharArea.value);
                bool  bHit = false;
                float xadd = 0;
                foreach (var c in cc)
                {
                    if (c.transform.parent.parent == transform)
                    {
                        continue;
                    }

                    if (aabb.Intersects(c.bounds))
                    {
                        float fdir = Mathf.Sign(boxpos.x - c.bounds.center.x);
                        var   cani = c.transform.parent.parent.GetComponent <PosePlus.AniPlayer>();
                        if (hold != null && cani == hold.aniplayer)
                        {
                            continue;
                        }
                        float fdist = (Mathf.Abs(boxpos.x - c.bounds.center.x) - boxsize.x / 2.0f - c.bounds.extents.x);

                        var cpos = c.transform.parent.parent.position;
                        cpos.x += fdir * fdist * 0.5f;
                        c.transform.parent.parent.position = cpos;

                        //if (cani.dir * fdir < 0)
                        //{
                        cani.wantpos = cpos;
                        //}

                        var lpos = transform.position;
                        lpos.x            += -fdir * fdist * 0.5f;
                        transform.position = lpos;
                        //Vector3 dist = boxpos.x - c.bounds.center.x;
                        //Vector3 dist = boxpos - c.bounds.center;
                        //if (dist.sqrMagnitude < 0.01f)
                        //{
                        //    dist = new Vector3((UnityEngine.Random.value - 0.5f) * 0.4f, 0, (UnityEngine.Random.value - 0.5f) * 0.4f);
                        //}
                        //dir.x += dist.x;
                        //dir.y = 0;
                        //if (Mathf.Abs(dir.x) > Mathf.Abs(dir.z)*0.5f)
                        //    dir.z = 0;
                        bHit = true;
                        //break;
                    }
                }
                if (bHit)
                {
                    //wantpos += dir.normalized * 6 * delta;
                }
            }
        }