Esempio n. 1
0
    void AnimEvent_PlaySfxGroup(string active_group)
    {
        string szSeparateExt = ";";

        string[] v = active_group.Split(szSeparateExt.ToCharArray());

        Debug.Assert(v.Length >= 2, "AnimEvent_ActiveSfxGroup is invalid : " + active_group);

        bool active = false;

        active = (v.Length < 2) ? true : (v[1].Equals("true") ? true : false);

        SetParam(v[0], delegate(GameObject go)
        {
            if (go != null)
            {
                Debug.Log("Active Sfx Group : " + active_group + " frameCount : " + Time.frameCount);

                if (active)
                {
                    SendEventToOwner(SfxEventType.ActiveSfxGroup, v[0]);
                }
                else
                {
                    SendEventToOwner(SfxEventType.DeActiveSfxGroup, v[0]);
                }
            }
        });
    }
Esempio n. 2
0
    sealed public override void _Init()
    {
        Debug.Assert(_uiState < UiState.Inited, @"UiCtrl(" + name + @") has already initialized.");

        if (!_isCreated)
        {
            _Create();
        }

        _ChangeUiState(UiState.Inited);

        _RelayUiParam();

        if (_uiParamBase != null && _uiParamBase.onLoadCompleted != null)
        {
            _uiParamBase.onLoadCompleted(this);
        }

        OnInit();

        // Refresh () is executed when refreshFlag is specified in OnInit ().
        TryRefresh();

        if (!_uiId.IsInvalid())
        {
            Debug.Log("<color=lightblue>Ui Activate :" + _uiId + "</color>");
        }
    }
Esempio n. 3
0
    //each time you want to get a new average, feed it the most recent value
    //and this method will return an average over the last SampleSize updates
    public Vector3 Update(Vector3 MostRecentValue)
    {
        Debug.Assert(m_iNextUpdateSlot < m_History.Count, "next update slot is fault count : " + m_iNextUpdateSlot);

        if (m_iNextUpdateSlot < m_History.Count)
        {
            //overwrite the oldest value with the newest
            m_History[m_iNextUpdateSlot++] = MostRecentValue;
        }

        //make sure m_iNextUpdateSlot wraps around.
        if (m_iNextUpdateSlot >= m_History.Count)
        {
            m_iNextUpdateSlot = 0;
        }

        //now to calculate the average of the history list
        //c++ code make a copy here, I use Zero method instead.
        //Another approach could be creating public clone() method in Vector2D ...
        Vector3 sum = m_ZeroValue;

        sum = Vector3.zero;

        for (int i = 0; i < m_History.Count; ++i)
        {
            sum += m_History[i];
        }

        sum = sum / m_History.Count;

        return(sum);
    }
Esempio n. 4
0
    /// <summary>
    ///  play sound using sfx
    /// </summary>
    /// <param name="index"> 0: method , 1: min , 2: max </param>
    public void AnimEvent_PlaySound(string index)
    {
        Debug.Assert(soundCue != null, "sfx - soundCue is null :" + gameObject.name);

        if (soundCue != null)
        {
            string   szSeparateExt = ";";
            string[] v             = index.Split(szSeparateExt.ToCharArray());

            Debug.Assert(v.Length >= 2, "PlaySound is invalid : " + gameObject.name + " arg : " + index);

            if (v.Length == 2)
            {
                soundCue.method  = (SoundCue.eMethod)System.Convert.ToInt32(v[0]);
                soundCue.playMin = soundCue.playMax = System.Convert.ToInt32(v[1]);
            }
            else if (v.Length > 2)
            {
                soundCue.method  = (SoundCue.eMethod)System.Convert.ToInt32(v[0]);
                soundCue.playMin = System.Convert.ToInt32(v[1]);
                soundCue.playMax = System.Convert.ToInt32(v[2]);
            }

            soundCue.PlaySound();

            SendEventToOwner(SfxEventType.PlaySound, index);
        }
    }
Esempio n. 5
0
    protected void _ChangeUiState(UiState state)
    {
        Debug.Assert(_uiState != state);
        _uiState = state;

        _onUiStateChanged(this, state);
    }
Esempio n. 6
0
    static string MakeFilePathForAccount(string fileName, string accountName, bool isOffline)
    {
        Debug.Assert(accountName != null);
        string offMode = isOffline ? "_offline" : string.Empty;

        return(string.Format("{0}/{1}{2}_{3}", Application.persistentDataPath, accountName, offMode, fileName));
    }
Esempio n. 7
0
    public SteeringBehaviour(AIAgent _entity)
    {
        m_entity = _entity;

        m_fWaypointSeekDistSq = wayPointSeekDist * wayPointSeekDist;

        Debug.Assert(m_entity != null, "entity is null");
    }
Esempio n. 8
0
    /// <summary>
    /// Called after subframe managers of MainFrame are initialized
    /// </summary>
    public void PostInit()
    {
        if (Application.isPlaying)
        {
            Debug.Assert(IsMainFramePosInitReady());
        }

        _postInitCalled = true;
    }
Esempio n. 9
0
    public void SetResultCb <T>(UiCallbackType <T> cb)
    {
        _resultCbD = cb;

        if (_resultCbD == null)
        {
            return;
        }

        Debug.Assert(GetResultType() == typeof(T), @"SetResultCb() - Callback types do not match. '" + this.GetType().ToString() + @"' The return type of type '" + GetResultType());
    }
Esempio n. 10
0
    public void SetDummyObject(string dummyObject_id)
    {
        GameObject _DummyObject = GetObjectInItem(dummyObject_id);

        Debug.Assert(_DummyObject != null, "EAWeapon DummyObject is null");

        if (_DummyObject != null)
        {
            fireDummyObject = _DummyObject;
        }
    }
Esempio n. 11
0
    void OnDestroy()
    {
        if (onSceneDestroy != null)
        {
            onSceneDestroy();
        }

        Debug.Log("EASceneLogic.OnDestroy()");

        Debug.Assert(instance != null);
        instance = null;
    }
Esempio n. 12
0
 public static Camera FindMainCamera()
 {
     for (int i = 0; i < Camera.allCameras.Length; i++)
     {
         Camera cam = Camera.allCameras[i];
         if (cam.tag == Tags.MainCamera)
         {
             return(cam);
         }
     }
     Debug.Assert(false, "No MainCamera");
     return(null);
 }
    void _ChangeState(State newState)
    {
        if (_state == newState)
        {
            Debug.Log("same State:" + newState);
            return;
        }
        Debug.Log("Change State:" + newState);

        // DownloadFiles만 같은 State로 전환가능. 나머진 불가.
        if (_state != State.DownloadEachFile && _state == newState)
        {
            Debug.Assert(false, "Invalid State Transition: " + _state + "-->" + newState);
            return;
        }

        _state = newState;


        switch (_state)
        {
        case State.DownloadMasterFile:
            _StartDownloadMasterFile();
            break;

        case State.CalcDownloadList:
            StartCoroutine(_BuildDownloadList());
            break;

        case State.ShowConfirmMsg:
            _ShowDownloadConfirmMsg();
            break;

        case State.DownloadEachFile:
            _StartDownloadBundleFile();
            break;

        case State.End:
            OnComplete(_errorDesc);
            break;

        case State.ConfirmRetry:
            _ShowRetryConfirmMsg();
            break;

        case State.WaitRetry:
            Debug.Log("WaitRetry. ContinuousNetworkErrorCnt:" + _continuousNetworkErrorCnt);
            _retryWaitTimer = 1;
            break;
        }
    }
Esempio n. 14
0
    public static Camera GetCamera(int depth)
    {
        for (int i = 0; i < Camera.allCameras.Length; i++)
        {
            Camera cam = Camera.allCameras[i];
            if (cam.depth == depth)
            {
                return(cam);
            }
        }

        Debug.Assert(false, "No Camera for depth: " + depth);

        return(null);
    }
Esempio n. 15
0
    public virtual void SetNextWaypoint()
    {
        Debug.Assert(m_WayPoints.Count > 0);

        int limit = (m_WayPoints.Count == 0) ? 1 : m_WayPoints.Count;

        if (m_bLooped)
        {
            currentIdx = (currentIdx + 1) % limit;
        }
        else
        {
            currentIdx = Math.Min(currentIdx + 1, limit - 1);
        }
    }
Esempio n. 16
0
    public override void _Deactivate()
    {
        if (this == null)
        {
            Debug.Assert(false);
            return;
        }

        if (gameObject == null)
        {
            Debug.Assert(false);
            return;
        }

        SetActive(false);
    }
Esempio n. 17
0
    private Object Load(string path)
    {
        Object obj = null;

        obj = CoreLoad <Object>(path);

        if (obj != null)
        {
            return(obj);
        }

        obj = Resources.Load <Object>(path);

        Debug.Assert(obj != null, "resource Load is null  path : " + path);

        return(obj);
    }
Esempio n. 18
0
    public T Load <T>(string path) where T : Object
    {
        T obj = null;

        obj = CoreLoad <T>(path);

        if (obj != null)
        {
            return(obj);
        }


        obj = (T)Resources.Load <T>(path);

        Debug.Assert(obj != null, "resource Load is null  path : " + path);

        return(obj);
    }
Esempio n. 19
0
    // initialization
    void Init()
    {
        if (null == _mainAudio)
        {
            _mainAudio             = gameObject.AddComponent <AudioSource>();
            _subAudio              = gameObject.AddComponent <AudioSource>();
            mainAudioOriVolume     = _mainAudio.volume;
            _mainAudio.volume      = GetVolume(SOUND_TYPE.BGM) * _mainAudio.volume;
            _mainAudio.loop        = true;
            _mainAudio.playOnAwake = false;
            _subAudio.playOnAwake  = false;
        }

        if (null == _defaultClip)
        {
            _defaultClip = ResourceManager.instance.Load <AudioClip>("Sound/se/Btn_Default");
        }

        Debug.Assert(_mainAudio != null, "main audio is null");
    }
Esempio n. 20
0
    public EA_CEffectNode CreateEffect(EA_EffectBaseInfo info)
    {
        info.m_eEffectState = eEffectState.ES_Load;

        //	Temporarily specify ObjId (sometimes temporary use by external system)
        bool bCreateTempId = false;

        if (CObjGlobal.InvalidEffectID == info.m_GDEffectId)
        {
            info.m_GDEffectId = (GDEffectID)m_pIDGenerator.GenerateID();
            bCreateTempId     = true;
        }

        EA_CEffectNode pEffectNode = null;

        if (bCreateTempId == false)
        {
            pEffectNode = GetEffectGroup(info.m_GDEffectId);
        }

        if (pEffectNode == null)
        {
            pEffectNode = new EA_CEffectNode();

            if (pEffectNode != null)
            {
                m_mapEffectList.Add(info.m_GDEffectId, pEffectNode);
            }
        }

        //	Enter and apply the generated information
        Debug.Assert(info != null, "No Effect Info");

        if (pEffectNode != null)
        {
            pEffectNode.SetObjInfo(info);
        }

        return(pEffectNode);
    }
Esempio n. 21
0
    private T CoreLoad <T>(string path) where T : Object
    {
        T obj = null;

        if (EAAssetBundleLoadModule.instance != null &&
            EAAssetBundleLoadModule.instance.GetUseBundle() == true)
        {
            obj = EAAssetBundleLoadModule.instance.Load <T>(path);

            if (obj != null)
            {
                return(obj);
            }

            Debug.Assert(obj != null, "bundle resource Load is null  path : " + path);
        }

#if UNITY_EDITOR
        obj = EAAssetBundleLoadModule.LoadLocal <T>(path);
#endif
        return(obj);
    }
Esempio n. 22
0
    /// <summary>
    ///
    /// </summary>
    /// <param name="parts_basic"></param>
    /// <returns></returns>
    private GameObject Attach(SkinnedMeshRenderer parts_basic)
    {
        Transform mesh = GetTransform("mesh");

        GameObject go = EAFrameUtil.AddChild(mesh.gameObject, parts_basic.gameObject);

        if (go != null)
        {
            go.SetActive(true);

            SkinnedMeshRenderer parts = go.GetComponent <SkinnedMeshRenderer>();

            if (parts != null)
            {
                EASKinInfo skinInfo = parts.GetComponent <EASKinInfo>();

                Debug.Assert(skinInfo != null, "SkinInfo not valid : " + parts_basic.gameObject.name);

                if (skinInfo != null)
                {
                    Transform[] bones = new Transform[skinInfo.BoneNames.Length];

                    for (int i = 0; i < skinInfo.BoneNames.Length; i++)
                    {
                        bones[i] = GetTransform(skinInfo.BoneNames[i]);
                    }

                    parts.rootBone = GetTransform(skinInfo.RootboneName);
                    parts.bones    = bones;
                    Bounds b = parts.localBounds;
                    b.center          = Vector3.zero;
                    parts.localBounds = b;
                }
            }
        }

        return(go);
    }
Esempio n. 23
0
    public void LoadScene(string sceneName, bool isPassFadeOutEffect = false, bool isPassFadeInEffect = false, float fadeOutValue = 0.5f, float fadeInValue = 0.5f, float fadeInDelayValue = 0.5f)
    {
        if (_state != State.None)
        {
            Debug.Assert(false, "warning loading scene");
            return;
        }

        this.isPassFadeInEffect = isPassFadeInEffect;

        this.fadeOutValue     = fadeOutValue;
        this.fadeInValue      = fadeInValue;
        this.fadeInDelayValue = fadeInDelayValue;

        if (isPassFadeOutEffect == false)
        {
            // Do screen fade effect
            StartLoad(sceneName);
        }
        else
        {
            StartLoad(sceneName);
        }
    }
Esempio n. 24
0
    /**
     *  this simply sums up all the active behaviors X their weights and
     *  truncates the result to the max available steering force before
     *  returning
     */
    private Vector3 CalculateWeightedSum()
    {
        if (On(behaviour_type.wall_avoidance))
        {
            steeringForce += WallAvoidance(m_entity.World().Walls()) * m_fWeightWallAvoidance;
        }

        if (On(behaviour_type.obstacle_avoidance))
        {
            steeringForce += ObstacleAvoidance(m_entity.World().Obstacles()) * m_fWeightObstacleAvoidance;
        }

        if (On(behaviour_type.evade))
        {
            Debug.Assert(m_pTargetAgent1 != null, "Evade target not assigned");
            steeringForce += Evade(m_pTargetAgent1) * m_fWeightEvade;
        }


        //these next three can be combined for flocking behavior (wander is
        //also a good behavior to add into this mix)

        if (On(behaviour_type.separation))
        {
            steeringForce += Separation(m_entity.GetAIGroup().Agents()) * m_fWeightSeparation;
        }

        if (On(behaviour_type.allignment))
        {
            steeringForce += Alignment(m_entity.GetAIGroup().Agents()) * m_fWeightAlignment;
        }

        if (On(behaviour_type.cohesion))
        {
            steeringForce += Cohesion(m_entity.GetAIGroup().Agents()) * m_fWeightCohesion;
        }

        if (On(behaviour_type.wander))
        {
            steeringForce += Wander() * m_fWeightWander;
        }

        if (On(behaviour_type.seek))
        {
            steeringForce += Seek(m_entity.VTarget()) * m_fWeightSeek;
        }

        if (On(behaviour_type.flee))
        {
            steeringForce += Flee(m_entity.VTarget()) * m_fWeightFlee;
        }

        if (On(behaviour_type.arrive))
        {
            steeringForce += Arrive(m_entity.VTarget(), m_deceleration) * m_fWeightArrive;
        }

        if (On(behaviour_type.pursuit))
        {
            Debug.Assert(m_pTargetAgent1 != null, "pursuit target not assigned");

            steeringForce += Pursuit(m_pTargetAgent1) * m_fWeightPursuit;
        }

        if (On(behaviour_type.offset_pursuit))
        {
            Debug.Assert(m_pTargetAgent1 != null, "pursuit target not assigned");
            Debug.Assert(m_vOffset.magnitude > 0, "No offset assigned");

            //steeringForce += OffsetPursuit(m_pTargetAgent1, m_vOffset) * m_fWeightOffestPursuit;
        }

        if (On(behaviour_type.interpose))
        {
            Debug.Assert(m_pTargetAgent1 != null && m_pTargetAgent2 != null, "Interpose agents not assigned");

            steeringForce += Interpose(m_pTargetAgent1, m_pTargetAgent2) * m_fWeightInterpose;
        }

        if (On(behaviour_type.hide))
        {
            Debug.Assert(m_pTargetAgent1 != null, "Hide target not assigned");

            steeringForce += Hide(m_pTargetAgent1, m_entity.World().Obstacles());
        }

        if (On(behaviour_type.follow_path))
        {
            steeringForce += FollowPath() * m_fWeightFollowPath;
        }

        steeringForce = MathUtil.Truncate(steeringForce, m_entity.MaxForce());

        return(steeringForce);
    }
Esempio n. 25
0
 //returns a random integer between x and y
 public static int RandInt(int x, int y)
 {
     Debug.Assert(y >= x, "<RandInt>: y is less than x");
     return(rand.Next(int.MaxValue - x) % (y - x + 1) + x);
 }
Esempio n. 26
0
    public void FireShoot()
    {
        EAActor pActor = GetOwnerActor();

        Debug.Assert(pActor != null, "FireShoot Actor is null");

        if (fireDummyObject != null && pActor != null)
        {
            ObjectInfo ObjInfo = new ObjectInfo();

            ObjInfo.spawnPos[0] = fireDummyObject.transform.position.x;
            ObjInfo.spawnPos[1] = fireDummyObject.transform.position.y;
            ObjInfo.spawnPos[2] = fireDummyObject.transform.position.z;

            ObjInfo.spawnAngle[0] = fireDummyObject.transform.rotation.eulerAngles.x;
            ObjInfo.spawnAngle[1] = fireDummyObject.transform.rotation.eulerAngles.y;
            ObjInfo.spawnAngle[2] = fireDummyObject.transform.rotation.eulerAngles.z;

            ObjInfo.m_ModelTypeIndex = WeaponInfo.uProjectileModelType;
            ObjInfo.m_objClassType   = WeaponInfo.m_objProjectileClassType;
            ObjInfo.SetObjName("projectile");

            ItemObjInfo itemInfo = new ItemObjInfo();

            EA_CCharBPlayer pCharBase = pActor.GetCharBase();

            if (pCharBase != null)
            {
                itemInfo.m_HavenUser = pCharBase.GetObjID();
            }

            if (ObjInfo.m_objClassType == default(Type))
            {
                ObjInfo.m_objClassType = typeof(EAProjectile);
            }

            itemInfo.m_eItemType = eItemObjType.IK_Projectile;
            EA_CItem pItem = EACObjManager.instance.CreateItem(ObjInfo, itemInfo);

            // Create if no bullet. Do not use pool
            if (pItem.GetLinkEntity() == null)
            {
                GameObject pGameObject = new GameObject("projectile", ObjInfo.m_objClassType);

                pGameObject.transform.position    = new Vector3(ObjInfo.spawnPos[0], ObjInfo.spawnPos[1], ObjInfo.spawnPos[2]);
                pGameObject.transform.eulerAngles = new Vector3(ObjInfo.spawnAngle[0], ObjInfo.spawnAngle[1], ObjInfo.spawnAngle[2]);

                pItem.SetLinkEntity(pGameObject);
                pItem.SetLinkItem(pGameObject.GetComponent <EAProjectile>());
            }

            GameObject   item        = pItem.GetLinkEntity();
            EAProjectile pProjectile = null;

            if (item != null)
            {
                pProjectile = item.GetComponent <EAProjectile>();
            }

            if (pProjectile != null)
            {
                if (ProjectileTransform.instance != null)
                {
                    pProjectile.transform.SetParent(ProjectileTransform.instance.transform);
                }

                // use sphereCollider
                Collider c = pProjectile.GetComponent <Collider>();

                if (c == null)
                {
                    SphereCollider sc = pProjectile.gameObject.AddComponent <SphereCollider>();
                    sc.radius = WeaponInfo.projectileRadius;
                }

                pProjectile.SetProjectileDir(fireDummyObject.transform.forward);

                pProjectile.SetOwnActor(itemInfo.m_HavenUser);

                pProjectile.SetWeapon(GetItemBase().GetObjID());

                pProjectile.SetWeaponInfo(WeaponInfo);

                Debug.Log("fire shoot - weapon user id :" + itemInfo.m_HavenUser + " projectile type : " + WeaponInfo.projectileType);
            }

            pItem.Use();
        }
    }
Esempio n. 27
0
    /**
     *  this method sums up the active behaviors by assigning a probabilty
     *  of being calculated to each behavior. It then tests the first priority
     *  to see if it should be calculated this simulation-step. If so, it
     *  calculates the steering force resulting from this behavior. If it is
     *  more than zero it returns the force. If zero, or if the behavior is
     *  skipped it continues onto the next priority, and so on.
     *
     *  NOTE: Not all of the behaviors have been implemented in this method,
     *        just a few, so you get the general idea
     */
    private Vector3 CalculateDithered()
    {
        //reset the steering force
        steeringForce = Vector3.zero;

        if (On(behaviour_type.wall_avoidance) && MathUtil.RandFloat() < Prm.prWallAvoidance)
        {
            steeringForce += WallAvoidance(m_entity.World().Walls()) * (m_fWeightWallAvoidance / Prm.prWallAvoidance);

            if (!MathUtil.IsZero(steeringForce))
            {
                steeringForce = MathUtil.Truncate(steeringForce, m_entity.MaxForce());

                return(steeringForce);
            }
        }

        if (On(behaviour_type.obstacle_avoidance) && MathUtil.RandFloat() < Prm.prObstacleAvoidance)
        {
            steeringForce += ObstacleAvoidance(m_entity.World().Obstacles()) * (m_fWeightObstacleAvoidance / Prm.prObstacleAvoidance);

            if (!MathUtil.IsZero(steeringForce))
            {
                steeringForce = MathUtil.Truncate(steeringForce, m_entity.MaxForce());

                return(steeringForce);
            }
        }

        if (On(behaviour_type.separation) && MathUtil.RandFloat() < Prm.prSeparation)
        {
            steeringForce += Separation(m_entity.GetAIGroup().Agents()) * (m_fWeightSeparation / Prm.prSeparation);

            if (!MathUtil.IsZero(steeringForce))
            {
                steeringForce = MathUtil.Truncate(steeringForce, m_entity.MaxForce());

                return(steeringForce);
            }
        }


        if (On(behaviour_type.flee) && MathUtil.RandFloat() < Prm.prFlee)
        {
            steeringForce += Flee(m_entity.VTarget()) * (m_fWeightFlee / Prm.prFlee);

            if (!MathUtil.IsZero(steeringForce))
            {
                steeringForce = MathUtil.Truncate(steeringForce, m_entity.MaxForce());

                return(steeringForce);
            }
        }

        if (On(behaviour_type.evade) && MathUtil.RandFloat() < Prm.prEvade)
        {
            Debug.Assert(m_pTargetAgent1 != null, "Evade target not assigned");

            steeringForce += Evade(m_pTargetAgent1) * (m_fWeightEvade / Prm.prEvade);

            if (!MathUtil.IsZero(steeringForce))
            {
                MathUtil.Truncate(steeringForce, m_entity.MaxForce());

                return(steeringForce);
            }
        }

        if (On(behaviour_type.allignment) && MathUtil.RandFloat() < Prm.prAlignment)
        {
            steeringForce += Alignment(m_entity.GetAIGroup().Agents()) * (m_fWeightAlignment / Prm.prAlignment);

            if (!MathUtil.IsZero(steeringForce))
            {
                steeringForce = MathUtil.Truncate(steeringForce, m_entity.MaxForce());

                return(steeringForce);
            }
        }

        if (On(behaviour_type.cohesion) && MathUtil.RandFloat() < Prm.prCohesion)
        {
            steeringForce += Cohesion(m_entity.GetAIGroup().Agents()) * (m_fWeightCohesion / Prm.prCohesion);

            if (!MathUtil.IsZero(steeringForce))
            {
                steeringForce = MathUtil.Truncate(steeringForce, m_entity.MaxForce());

                return(steeringForce);
            }
        }


        if (On(behaviour_type.wander) && MathUtil.RandFloat() < Prm.prWander)
        {
            steeringForce += Wander() * (m_fWeightWander / Prm.prWander);

            if (!MathUtil.IsZero(steeringForce))
            {
                steeringForce = MathUtil.Truncate(steeringForce, m_entity.MaxForce());

                return(steeringForce);
            }
        }

        if (On(behaviour_type.seek) && MathUtil.RandFloat() < Prm.prSeek)
        {
            steeringForce += Seek(m_entity.VTarget()) * (m_fWeightSeek / Prm.prSeek);

            if (!MathUtil.IsZero(steeringForce))
            {
                steeringForce = MathUtil.Truncate(steeringForce, m_entity.MaxForce());

                return(steeringForce);
            }
        }

        if (On(behaviour_type.arrive) && MathUtil.RandFloat() < Prm.prArrive)
        {
            steeringForce += Arrive(m_entity.VTarget(), m_deceleration) * (m_fWeightArrive / Prm.prArrive);

            if (!MathUtil.IsZero(steeringForce))
            {
                steeringForce = MathUtil.Truncate(steeringForce, m_entity.MaxForce());

                return(steeringForce);
            }
        }

        return(steeringForce);
    }
Esempio n. 28
0
    /**
     *  this method calls each active steering behavior in order of priority
     *  and acumulates their forces until the max steering force magnitude
     *  is reached, at which time the function returns the steering force
     *  accumulated to that  point
     */
    private Vector3 CalculatePrioritized()
    {
        Vector3 force = Vector3.zero;

        if (On(behaviour_type.wall_avoidance))
        {
            force = WallAvoidance(m_entity.World().Walls()) * m_fWeightWallAvoidance;

            if (!AccumulateForce(ref steeringForce, force))
            {
                return(steeringForce);
            }
        }

        if (On(behaviour_type.obstacle_avoidance))
        {
            force = ObstacleAvoidance(m_entity.World().Obstacles()) * m_fWeightObstacleAvoidance;

            if (!AccumulateForce(ref steeringForce, force))
            {
                return(steeringForce);
            }
        }

        if (On(behaviour_type.evade))
        {
            Debug.Assert(m_pTargetAgent1 != null, "Evade target not assigned");

            force = Evade(m_pTargetAgent1) * m_fWeightEvade;

            if (!AccumulateForce(ref steeringForce, force))
            {
                return(steeringForce);
            }
        }


        if (On(behaviour_type.flee))
        {
            force = Flee(m_entity.VTarget()) * m_fWeightFlee;

            if (!AccumulateForce(ref steeringForce, force))
            {
                return(steeringForce);
            }
        }


        //these next three can be combined for flocking behavior (wander is
        //also a good behavior to add into this mix)
        if (On(behaviour_type.separation))
        {
            force = Separation(m_entity.GetAIGroup().Agents()) * m_fWeightSeparation;

            if (!AccumulateForce(ref steeringForce, force))
            {
                return(steeringForce);
            }
        }

        if (On(behaviour_type.allignment))
        {
            force = Alignment(m_entity.GetAIGroup().Agents()) * m_fWeightAlignment;

            if (!AccumulateForce(ref steeringForce, force))
            {
                return(steeringForce);
            }
        }

        if (On(behaviour_type.cohesion))
        {
            force = Cohesion(m_entity.GetAIGroup().Agents()) * m_fWeightCohesion;

            if (!AccumulateForce(ref steeringForce, force))
            {
                return(steeringForce);
            }
        }


        if (On(behaviour_type.seek))
        {
            force = Seek(m_entity.VTarget()) * m_fWeightSeek;

            if (!AccumulateForce(ref steeringForce, force))
            {
                return(steeringForce);
            }
        }


        if (On(behaviour_type.arrive))
        {
            force = Arrive(m_entity.VTarget(), m_deceleration) * m_fWeightArrive;

            if (!AccumulateForce(ref steeringForce, force))
            {
                return(steeringForce);
            }
        }

        if (On(behaviour_type.wander))
        {
            force = Wander() * m_fWeightWander;

            if (!AccumulateForce(ref steeringForce, force))
            {
                return(steeringForce);
            }
        }

        if (On(behaviour_type.pursuit))
        {
            Debug.Assert(m_pTargetAgent1 != null, "pursuit target not assigned");

            force = Pursuit(m_pTargetAgent1) * m_fWeightPursuit;

            if (!AccumulateForce(ref steeringForce, force))
            {
                return(steeringForce);
            }
        }

        if (On(behaviour_type.offset_pursuit))
        {
            //Debug.Assert(m_pTargetAgent1 != null  ,"pursuit target not assigned");
            //Debug.Assert(m_vOffset != Vector3.zero,"No offset assigned");

            //force = OffsetPursuit(m_pTargetAgent1, m_vOffset);

            //if (!AccumulateForce(ref steeringForce, force))
            //{
            //    return steeringForce;
            //}
        }

        if (On(behaviour_type.interpose))
        {
            Debug.Assert(m_pTargetAgent1 != null && m_pTargetAgent2 != null, "Interpose agents not assigned");

            force = Interpose(m_pTargetAgent1, m_pTargetAgent2) * m_fWeightInterpose;

            if (!AccumulateForce(ref steeringForce, force))
            {
                return(steeringForce);
            }
        }

        if (On(behaviour_type.hide))
        {
            Debug.Assert(m_pTargetAgent1 != null, "Hide target not assigned");

            force = Hide(m_pTargetAgent1, m_entity.World().Obstacles()) * m_fWeightHide;

            if (!AccumulateForce(ref steeringForce, force))
            {
                return(steeringForce);
            }
        }


        if (On(behaviour_type.follow_path))
        {
            force = FollowPath() * m_fWeightFollowPath;

            if (!AccumulateForce(ref steeringForce, force))
            {
                return(steeringForce);
            }
        }

        return(steeringForce);
    }
Esempio n. 29
0
    /// <summary>
    ///
    /// </summary>
    protected void FindWeapon()
    {
        EA_CCharBPlayer pActor = GetCharBase();

        EA_Equipment pEquipment = null;

        //2017 1126 Consider even without weapons
        m_pCurWeapon = null;

        if (pActor != null)
        {
            pEquipment = EA_ItemManager.instance.Equip_FindEqipment(pActor.GetObjID());
        }

        if (pEquipment != null)
        {
            EA_CItemUnit pItemUnit = pEquipment.GetCurrentItem();

            if (pItemUnit != null)
            {
                EA_CItem pItem = EACObjManager.instance.GetItemObject(pItemUnit.GetObjId());

                if (pItem != null)
                {
                    Debug.Assert(pItem.GetLinkItem() != null, "EAActor FindWeapon pItem.GetLinkItem() is null");

                    if (pItem.GetLinkItem() != null)
                    {
                        m_pCurWeapon = (EAWeapon)pItem.GetLinkItem() as EAWeapon;
                    }
                }
            }
        }

        //  [5/28/2018 puos] bug fixed
        if (m_pCurWeapon == null)
        {
            if (pActor != null)
            {
                pEquipment = EA_ItemManager.instance.Equip_FindEqipment(pActor.GetObjID());
            }

            if (pEquipment != null)
            {
                EA_CItemUnit pItemUnit = pEquipment.GetCurrentItem();

                if (pItemUnit != null)
                {
                    EA_CItem pItem = EACObjManager.instance.GetItemObject(pItemUnit.GetObjId());

                    if (pItem != null)
                    {
                        Debug.Assert(pItem.GetLinkItem() != null, "EAActor FindWeapon2 pItem.GetLinkItem() is null");

                        if (pItem.GetLinkItem() != null)
                        {
                            m_pCurWeapon = (EAWeapon)pItem.GetLinkItem() as EAWeapon;
                        }
                    }
                }
            }
        }
    }
Esempio n. 30
0
 void OnDestroy()
 {
     Debug.Assert(instance != null);
 }