Exemple #1
0
 public virtual void Init(FCObject owner)
 {
     _owner   = owner as ActionController;
     _faction = _owner.Faction;
     if (_shakeLevel == EnumShakeEffect.shake3_loop)
     {
         _haveShakeLoop = true;
     }
     else
     {
         _haveShakeLoop = false;
     }
 }
    public static FC_AC_FACTIOH_TYPE GetFaction(string data)
    {
        FC_AC_FACTIOH_TYPE val = (FC_AC_FACTIOH_TYPE)(System.Enum.Parse(typeof(FC_AC_FACTIOH_TYPE), data));

        return(val);
    }
Exemple #3
0
    public void GetEnemyTargetsBySight(Transform selfTransform, float sightLength, float sightLength1, FC_AC_FACTIOH_TYPE eaf, float angle, ref List <ActionController> acTargetList)
    {
        float sightLengthSqrt  = sightLength * sightLength;
        float sightLengthSqrt1 = sightLength1 * sightLength1;

        acTargetList.Clear();
        foreach (KeyValuePair <FC_AC_FACTIOH_TYPE, List <ActionController> > acList in _acSet)
        {
            if (acList.Key != eaf)
            {
                foreach (ActionController ac in acList.Value)
                {
                    if (ac == null || !ac.IsAlived)
                    {
                        continue;
                    }
                    float lenSqrt = (ac.ThisTransform.localPosition - selfTransform.localPosition).sqrMagnitude;
                    if (lenSqrt < sightLengthSqrt1)
                    {
                        acTargetList.Add(ac);
                    }
                    else if (lenSqrt < sightLengthSqrt)
                    {
                        if (angle >= 360)
                        {
                            acTargetList.Add(ac);
                        }
                        else
                        {
                            float anglex = Vector3.Angle(selfTransform.forward, ac.ThisTransform.localPosition - selfTransform.localPosition);
                            if (anglex < angle / 2)
                            {
                                acTargetList.Add(ac);
                            }
                        }
                    }
                }
            }
        }
    }
Exemple #4
0
    public ActionController GetEnemyTargetBySight(Transform selfTransform, float sightLength, float sightLength1, FC_AC_FACTIOH_TYPE eaf, float angleMin, float angleMax, bool needTheNearest)
    {
        if (Mathf.Approximately(angleMin, angleMax))
        {
            return(GetEnemyTargetBySight(selfTransform, sightLength, sightLength1, eaf, angleMin, needTheNearest));
        }
        float            sightLengthSqrt        = sightLength * sightLength;
        float            sightLengthSqrt1       = sightLength1 * sightLength1;
        float            sightLengthSqrtSource  = sightLength * sightLength;
        float            sightLengthSqrt1Source = sightLength1 * sightLength1;
        ActionController nearestAC = null;

        foreach (KeyValuePair <FC_AC_FACTIOH_TYPE, List <ActionController> > acList in _acSet)
        {
            if (acList.Key != eaf)
            {
                foreach (ActionController ac in acList.Value)
                {
                    if (ac == null || !ac.IsAlived)
                    {
                        continue;
                    }
                    float lenSqrt = (ac.ThisTransform.localPosition - selfTransform.position).sqrMagnitude;
                    if (lenSqrt < sightLengthSqrt1 ||
                        (ac.DangerLevel >= FCConst.ELITE_DANGER_LEVEL && lenSqrt < sightLengthSqrt1Source))
                    {
                        if (needTheNearest)
                        {
                            SetNearestAC(lenSqrt, ac, ref sightLengthSqrt1, ref nearestAC, sightLengthSqrt1Source);
                        }
                        else
                        {
                            return(ac);
                        }
                    }
                    else if (lenSqrt < sightLengthSqrt ||
                             (ac.DangerLevel >= FCConst.ELITE_DANGER_LEVEL && lenSqrt < sightLengthSqrtSource))
                    {
                        float angle  = ((1 - lenSqrt / sightLengthSqrt) * (angleMax - angleMin) + angleMin) / 2;
                        float anglex = Vector3.Angle(selfTransform.forward, ac.ThisTransform.localPosition - selfTransform.position);
                        if (anglex <= angle)
                        {
                            if (needTheNearest)
                            {
                                SetNearestAC(lenSqrt, ac, ref sightLengthSqrt, ref nearestAC, sightLengthSqrtSource);
                            }
                            else
                            {
                                return(ac);
                            }
                        }
                    }
                }
            }
        }
        return(nearestAC);
    }
Exemple #5
0
 public bool EnemyIsInRanger(Vector3 direction, Vector3 orgPos, float sightLengthSqrt, FC_AC_FACTIOH_TYPE eaf)
 {
     foreach (KeyValuePair <FC_AC_FACTIOH_TYPE, List <ActionController> > acList in _acSet)
     {
         if (acList.Key != eaf)
         {
             foreach (ActionController ac in acList.Value)
             {
                 if (ac == null || !ac.IsAlived)
                 {
                     continue;
                 }
                 float lenSqrt = (ac.ThisTransform.localPosition - orgPos).sqrMagnitude;
                 if (lenSqrt < sightLengthSqrt)
                 {
                     Vector3 pos1 = ac.ThisTransform.localPosition - orgPos;
                     pos1.y = 0;
                     float anglex = Vector3.Angle(direction, pos1);
                     if (anglex <= 30)
                     {
                         return(true);
                     }
                 }
             }
         }
     }
     return(false);
 }
Exemple #6
0
    /// <summary>
    /// Gets the target by forward.
    /// </summary>
    /// <returns>
    /// The target has similar forward with self
    /// </returns>
    /// <param name='selfTransform'>
    /// Self transform.
    /// </param>
    /// <param name='sightLength'>
    /// Sight length. the target must in self sight
    /// </param>
    public ActionController GetTargetByForward(Transform selfTransform, float sightLength, FC_AC_FACTIOH_TYPE eaf)
    {
        float            sightLengthSqrt = sightLength * sightLength;
        ActionController nearestAC       = null;
        float            angleN          = 999;

        foreach (KeyValuePair <FC_AC_FACTIOH_TYPE, List <ActionController> > acList in _acSet)
        {
            if (acList.Key != eaf)
            {
                foreach (ActionController ac in acList.Value)
                {
                    if (ac == null || !ac.IsAlived)
                    {
                        continue;
                    }
                    float lenSqrt = (ac.ThisTransform.localPosition - selfTransform.position).sqrMagnitude;
                    if (lenSqrt < sightLengthSqrt)
                    {
                        float anglex = Vector3.Angle(selfTransform.forward, ac.ThisTransform.localPosition - selfTransform.position);
                        if (anglex < angleN)
                        {
                            nearestAC = ac;
                            angleN    = anglex;
                        }
                    }
                }
            }
        }
        return(nearestAC);
    }