Ejemplo n.º 1
0
    public static Vector3 GetTargetCenter(ISkillTarget target)
    {
        SkillRunner runner = target as SkillRunner;

        if (runner != null && runner.GetComponent <Collider>() != null)
        {
            AiObject aiObj = runner as AiObject;
            if (aiObj != null)
            {
                return(aiObj.center);
            }
            else
            {
                return(AiUtil.GetColliderCenter(runner.GetComponent <Collider>()));
            }
        }
        else
        {
            //CreationSkillRunner creation = runner as CreationSkillRunner;
            //if (creation != null)
            //return creation.transform.TransformPoint(creation.LocalBounds.center);
            // else
            // return target.GetPosition();
        }
        return(Vector3.zero);
    }
Ejemplo n.º 2
0
    public static Vector3 GetShootPosition(ISkillTarget target)
    {
        SkillRunner runner = target as SkillRunner;

        if (runner != null && runner.GetComponent <Collider>() != null)
        {
            AiObject aiObj = runner as AiObject;
            if (aiObj != null)
            {
                if (aiObj.model != null)
                {
                    Rigidbody[] rigids = aiObj.model.GetComponentsInChildren <Rigidbody>();
                    if (rigids != null && rigids.Length > 0)
                    {
                        return(rigids[Random.Range(0, rigids.Length)].worldCenterOfMass);
                    }
                }

                return(aiObj.center);
            }
            else
            {
                return(AiUtil.GetColliderCenter(runner.GetComponent <Collider>()));
            }
        }
        else
        {
            //CreationSkillRunner creation = runner as CreationSkillRunner;
            //if (creation != null)
            //	return creation.transform.TransformPoint(creation.LocalBounds.center);
            //else
            //	return target.GetPosition();
        }
        return(Vector3.zero);
    }