Exemple #1
0
    // Use this for initialization
    public CameraState3RD(AgentHuman owner) : base(owner)
    {
        DefaultPos    = Owner.transform.Find("CameraTargetPos");
        DefaultLookat = Owner.transform.Find("CameraTargetDir");

        Offset                   = new GameObject("CameraOffset3rd");
        OffsetTransform          = Offset.transform;
        OffsetTransform.parent   = Owner.transform;
        OffsetTransform.position = DefaultPos.position;
        OffsetTransform.LookAt(DefaultLookat.position);

        Offset.SetActive(false);
    }
    //clone the Ragdoll setup from BaseRagdoll to every (suitable) selected object
    void CloneToSelection()
    {
//		DBG_copied = false;

        Debug.Log("Ragdoll Cloner: base=" + (BaseRagdoll ? BaseRagdoll.name : "null"));

        if (!BaseRagdoll)
        {
            Debug.Log("Ragdoll Cloner: select a valid ragdoll agent first.");
            return;
        }

        //
        AgentHuman baseAgent = BaseRagdoll.GetComponent <AgentHuman>();

        UnityEngine.Object[] activeGOs = Selection.GetFiltered(typeof(AgentHuman), SelectionMode.Editable | SelectionMode.TopLevel);

        foreach (UnityEngine.Object obj in activeGOs)
        {
            AgentHuman agent = (obj as AgentHuman);

            if (agent == baseAgent)
            {
                Debug.Log("Ragdoll Cloner: SKIPPING target=" + agent.name + " - the same object as Base Ragdoll.");
                continue;
            }

            if (!agent.RagdollRoot)
            {
                Debug.Log("Ragdoll Cloner: SKIPPING target=" + agent.name + " - AgentHuman.RagdollRoot is NOT SET.");
                continue;                                               //do not proceed with any selected non-ragdoll agents
            }

            Debug.Log("Ragdoll Cloner: target=" + agent.name);

            //
            CloneRagdoll(baseAgent.RagdollRoot, agent.RagdollRoot);

            //save the prefab modifications
//			UnityEngine.Object	prefab = PrefabUtility.GetPrefabObject(obj);
//			PropertyModification[] mod = PrefabUtility.GetPropertyModifications(prefab);		//GetPrefabObject() ?
//			PropertyModification[] mod = PrefabUtility.GetPropertyModifications(obj);		//GetPrefabObject() ?
//			PrefabUtility.SetPropertyModifications(prefab, mod);
//			PrefabUtility.SetPropertyModifications(obj, mod);
//			PrefabUtility.SetPropertyModifications(BaseRagdoll, mod);
        }

        //save modifications
        AssetDatabase.SaveAssets();
    }
Exemple #3
0
    public override bool IsFriend(AgentHuman target)
    {
        if (m_Owner == null)
        {
            return(true);
        }

        if (target == m_Owner)
        {
            return(true);
        }

        return(m_Owner.IsFriend(target));
    }
    public static AgentHuman SelectNextAgentToFollow()
    {
        if (mSwitchToPlayer)
        {
            // we already selected next player, using NEXT/PREV buttons
            mSwitchToPlayer = false;

            return(mLastHumanSpectator);
        }

        AgentHuman SelectedAgent = null;

        List <AgentHuman> list = new List <AgentHuman>();

        foreach (KeyValuePair <uLink.NetworkPlayer, ComponentPlayer> pair in Player.Players)
        {
            list.Add(pair.Value.Owner);
        }

        // to prevent of selection of the same human
        if (null != mLastHumanSpectator && list.Count > 1)
        {
            list.Remove(mLastHumanSpectator);
        }

        // we prefer alive human
        foreach (AgentHuman Human in list)
        {
            if (Human.IsAlive)
            {
                for (int i = list.Count - 1; i >= 0; i--)
                {
                    if (!list[i].IsAlive)
                    {
                        list.RemoveAt(i);
                    }
                }
                break;
            }
        }

        if (list.Count > 0)
        {
            SelectedAgent = list[Random.Range(0, list.Count)];
        }

        SetHumanSpectator(SelectedAgent);

        return(SelectedAgent);
    }
Exemple #5
0
    public static SensorBase Create(E_SensorType sensorType, AgentHuman owner)
    {
        switch (sensorType)
        {
        case E_SensorType.CoverPlayer:
            return(new SensorCoverPlayer(owner));

        case E_SensorType.EyePlayer:
            return(new SensorEyesPlayer(owner));

        default:
            Debug.LogError("SensorFactory -  unknow type " + sensorType);
            return(null);
        }
    }
Exemple #6
0
    protected bool ValidateHitAgainstEnemy(RaycastHit hit)
    {
#if !DEADZONE_CLIENT
        if (uLink.Network.isServer)
        {
            AgentHuman other = hit.transform.gameObject.GetComponent <AgentHuman>();
            if ((other != null) && !other.IsFriend(Agent))
            {
                return(ServerAnticheat.ValidateHit(Agent, this, hit));
            }
        }
#endif

        return(true);
    }
Exemple #7
0
    public GOAPManager(AgentHuman ai)
    {
        Owner = ai;
        Map   = new AStarGOAPMap();       //Initialise the AStar Planner
        //Map.Initialise(Owner);
        //Map.BuildActionsEffectsTable();//Build the action effects table

        Storage = new AStarStorage();

        Goal = new AStarGOAPGoal();

        AStar = new AStarEngine();

        //AStar.Setup(Goal,Storage,Map);
    }
Exemple #8
0
    // Use this for initialization
    public CameraStateKnockdown(AgentHuman owner) : base(owner)
    {
        DefaultPos    = Owner.transform.Find("CameraTargetPos");
        DefaultLookat = Owner.transform.Find("CameraTargetDir");

        Offset = new GameObject("CameraOffsetKnockdown");

        OffsetTransform          = Offset.transform;
        OffsetTransform.parent   = Owner.transform;
        OffsetTransform.position = DefaultPos.position;
        OffsetTransform.LookAt(DefaultLookat.position);

        OffsetTransform.RotateAround(DefaultLookat.position, DefaultLookat.right, 25);
        OffsetTransform.RotateAround(DefaultLookat.position, DefaultLookat.up, 180);
    }
    // Implement your own editor GUI here.
    void OnGUI()
    {
        GUIEditorUtils.LookLikeControls();

        //base ragdoll field
        GUILayout.Space(20);
        EditorGUILayout.BeginHorizontal();
        GUILayout.Label("Base Ragdoll:", GUILayout.Width(95), GUILayout.ExpandWidth(false));

        BaseRagdoll = (GameObject)EditorGUILayout.ObjectField(BaseRagdoll, typeof(GameObject), true, GUILayout.Width(220), GUILayout.ExpandWidth(false));

        EditorGUILayout.EndHorizontal();
        GUILayout.Space(10);

        //clone button
        EditorGUILayout.BeginHorizontal("box");
        GUILayout.Label("", GUILayout.Width(90), GUILayout.ExpandWidth(false));

        UnityEngine.Object[] activeGOs = Selection.GetFiltered(typeof(AgentHuman), SelectionMode.Editable | SelectionMode.TopLevel);
        string caption = ("Clone To Selection: " + activeGOs.Length + (activeGOs.Length == 1 ? " object" : " objects"));

        if (GUILayout.Button(caption, GUILayout.Width(200)))                                    //beny: possible to use also GUILayout.ExpandWidth(false), but absolute width is better for this
        {
            CloneToSelection();
        }

        GUILayout.Label("", GUILayout.Width(100), GUILayout.ExpandWidth(false));
        GUILayout.Space(20);
        EditorGUILayout.EndHorizontal();

        GUI.changed = false;


//		if (GUI.changed)
        {
            //check the base ragdoll
            if (BaseRagdoll)
            {
                AgentHuman agent = BaseRagdoll.GetComponent <AgentHuman>();

                if (!agent || !agent.RagdollRoot)                                       //do not allow other objects to be picked in
                {
                    BaseRagdoll = null;
                    this.Repaint();
                }
            }
        }
    }
Exemple #10
0
    //
    public void OnProjectileHit(Projectile projectile)
    {
        if (!Owner && GameObj.transform.parent)
        {
            Owner = GameObj.transform.parent.gameObject.GetFirstComponentUpward <AgentHuman>();
        }

        if ((Owner != null) && (Owner.IsFriend(projectile.Agent) == true))
        {
            projectile.ignoreThisHit = true;
            return;
        }

        Vector3 impulse = (projectile.Transform.forward * (projectile.Impulse * 0.005f)) + (Vector3.up * (projectile.Impulse * 0.002f));

//		Debug.Log ("HatObject, impulse=" + impulse.ToString("F5") + ", projectile.Impulse=" + projectile.Impulse.ToString("F5") + ", impulse.magnitude=" + impulse.magnitude);
//		Debug.DrawLine(GameObj.transform.position, GameObj.transform.position + impulse, Color.red, 5.0f);

        if (uLink.Network.isServer)
        {
            if (Owner)
            {
                //send impulse to clients
                Owner.NetworkView.RPC("ShotOffHat", uLink.RPCMode.Others, impulse, false);

                //shot off the hat on server
                Owner.ShotOffHat(impulse, true);
            }
        }
        else
        {
            //apply impulse to a hat which is already shot off
            if (null == GameObj.transform.parent)
            {
                GameObj.GetComponent <Rigidbody>().isKinematic = false;
                GameObj.GetComponent <Rigidbody>().useGravity  = true;

                GameObj.GetComponent <Rigidbody>().AddForce(impulse, ForceMode.Impulse);
            }
            else
            {
                return;                 // on client and still on head --> do nothing
            }
        }

        DestroyTime = Time.timeSinceLevelLoad + 20;         //destroy hat after 20 seconds
    }
Exemple #11
0
    public virtual void UnlinkFromOwner()
    {
        //Debug.Log(name + " Unlink to owner", this);

        Owner = null;
        SetParent(null);

        Transform.localPosition = Vector3.zero;
        Transform.localRotation = Quaternion.identity;

        if (RBody != null)
        {
            RBody.isKinematic = true;
        }

        ShowWeapon(false);
    }
Exemple #12
0
    public void MergeStates(AgentHuman ai, WorldState currentState, WorldState goalState)
    {
        for (E_PropKey iProp = 0; iProp < E_PropKey.Count; ++iProp)
        {
            // Continue if property already exists in current
            // world state.

            if ((!goalState.IsWSPropertySet(iProp)) || // if not set in goal
                (currentState.IsWSPropertySet(iProp))) //if already set
            {
                continue;                              // then continue
            }

            // and set real property from Agent to current
            WorldStateProp prop = ai.WorldState.GetWSProperty((E_PropKey)iProp);
            currentState.SetWSProperty(prop);
        }
    }
Exemple #13
0
    void TakeDamage(AgentHuman inAttacker, float inDamage, Vector3 inImpuls, E_WeaponID weaponID, E_ItemID itemID)
    {
        // Only server players should take damage or die as a consequence of damage. Client players die from server messages.
        if (uLink.Network.isServer)
        {
            if (m_Health - inDamage > 0)
            {
                m_Health = Mathf.Max(0, m_Health - inDamage);
            }
            else if (m_Health > 0)
            {
                m_Health = 0;

                PPIManager.Instance.ServerAddScoreForTurretKill(inAttacker.NetworkView.owner, GoldReward);
                OnDeactivation();
            }
        }
    }
Exemple #14
0
    void InitWorker(AgentHuman Human)
    {
        m_Owner = Human;

        transform.rotation = m_Owner.Transform.rotation;

        m_ProjInitSettings                 = new Projectile.InitSettings();
        m_ProjInitSettings.Agent           = m_Owner;
        m_ProjInitSettings.IgnoreTransform = m_Owner.Transform;
        m_ProjInitSettings.Speed           = m_WpnSettings.m_ProjSpeed;
        m_ProjInitSettings.Damage          = m_WpnSettings.m_Damage;
        m_ProjInitSettings.Impulse         = m_WpnSettings.m_ProjImpuls;

        m_Owner.GadgetsComponent.RegisterLiveGadget(ItemID, GameObject);

        m_ProjInitSettings.ItemID = ItemID;
        Icons.SetTeamIcon(m_Owner.Team);
    }
Exemple #15
0
        // Copy constructor. Create clone of inSettings object.
        public InitSettings(InitSettings inSettings)
        {
            Damage   = inSettings.Damage;
            Impulse  = inSettings.Impulse;
            Speed    = inSettings.Speed;
            Agent    = inSettings.Agent;
            WeaponID = inSettings.WeaponID;
            ItemID   = inSettings.ItemID;
            Homing   = inSettings.Homing;
            Silencer = inSettings.Silencer;

            IgnoreTransform = inSettings.IgnoreTransform;

            if (null == Agent)
            {
                Debug.LogWarning("### Projectile.InitSettings() : unexpected null agent. WeaponID : " + WeaponID + ", ItemID : " + ItemID);
            }
        }
Exemple #16
0
    public Item(PlayerPersistantInfo ppi, AgentHuman owner, E_ItemID itemID)
    {
        Owner    = owner;
        Settings = ItemSettingsManager.Instance.Get(itemID);

        if (Settings.ItemBehaviour == E_ItemBehaviour.Booster)
        {
            Timer = Settings.BoostTimer;
        }
        else
        {
            Timer = Settings.Timer;
        }
        Detected = false;

        if (Settings.Consumable)
        {
// for cunsumables get real count from inventory !!!
            PPIItemData data = ppi.InventoryList.Items.Find(item => item.ID == itemID);
            Count = data.Count > Settings.MaxCountInMission ? Settings.MaxCountInMission : data.Count;
        }
        else
        {
            Count = Settings.Count > Settings.MaxCountInMission ? Settings.MaxCountInMission : Settings.Count;

            if (ppi.Upgrades.OwnsUpgrade(E_UpgradeID.ExplosivePouch))
            {
                switch (itemID)
                {
                case E_ItemID.GrenadeEMP:
                case E_ItemID.GrenadeEMPII:
                case E_ItemID.GrenadeFlash:
                case E_ItemID.GrenadeFrag:
                case E_ItemID.GrenadeFragII:
                case E_ItemID.Mine:
                case E_ItemID.MineEMP:
                case E_ItemID.MineEMPII:
                    ++Count;
                    break;
                }
            }
        }
        OrigCount = Count;
    }
Exemple #17
0
    E_Team ServerGetAreaOwner()
    {
        int good = 0;
        int bad  = 0;

        foreach (KeyValuePair <uLink.NetworkPlayer, ComponentPlayer> pair in Player.Players)
        {
            AgentHuman a = pair.Value.Owner;

            if (a.IsAlive == false)
            {
                continue;
            }

            if (a.Position.y - Center.y < -1)
            {
                continue;
            }

            if ((Center - a.Position).sqrMagnitude > Range * Range)
            {
                continue;
            }

            if (a.Team == E_Team.Bad)
            {
                bad++;
            }
            else
            {
                good++;
            }
        }

        Temp[E_Team.Good] = good;
        Temp[E_Team.Bad]  = bad;

        if ((bad == 0 && good == 0) || (bad > 0 && good > 0))         // none or both teams are near
        {
            return(E_Team.None);
        }

        return(bad > 0 ? E_Team.Bad : E_Team.Good);
    }
Exemple #18
0
    // -----------------

    // -----
    public void Initialize(AgentHuman owner, E_WeaponID id)
    {
        Settings                  = WeaponSettingsManager.Instance.Get(id);
        InitProjSettings          = new Projectile.InitSettings();
        InitProjSettings.WeaponID = Settings.ID;
        InitProjSettings.Impulse  = Settings.BaseData.Impulse;
        InitProjSettings.Speed    = Settings.BaseData.Speed;      // to have valid valid values here if InitializeModifiersFromUpgrades fails
        InitProjSettings.Damage   = Settings.BaseData.Damage;

        InitializeModifiersFromUpgrades(owner);
        _AmmoInClip   = MaxAmmoInClip;
        _AmmoInWeapon = MaxAmmoInWeapon;
        GameObject    = gameObject;
        Transform     = transform;
        Audio         = GetComponent <AudioSource>();
        RBody         = GetComponent <Rigidbody>();
//		Renderer		= renderer;
        TransformShot = transform.FindChild("Shoot");
    }
    internal void OnCollisionEnter(Collision collision)
    {
        //Debug.Log(name + " OnCollisionEnter " + collision.gameObject.name);

        if (IsInvoking("Explode") == false)
        {
            return;
        }

        // ignore collisions with owner and his transforms...
        if (Agent && collision.transform.IsChildOf(Agent.Transform))
        {
            return;
        }

        Agent      agent = collision.gameObject.GetComponent <Agent>();
        HitZone    hz    = collision.gameObject.GetComponent <HitZone>();
        AgentHuman human = agent as AgentHuman;

        if (human && human.BlackBoard.GrenadesExplodeOnHit == false)
        {
            if (m_PlayHitSound > 0)
            {
                m_PlayHitSound--;
                PlayHitSound(GetComponent <Collider>().gameObject.layer);
            }
        }
        else if (agent)
        {
            // grenade must explode immediately, if we hit player
            Explode();
        }
        else if (hz)
        {
            // grenade must explode immediately, if we hit player
            Explode();
        }
        else if (m_WaterVolume == null && m_PlayHitSound > 0)
        {
            m_PlayHitSound--;
            PlayHitSound(GetComponent <Collider>().gameObject.layer);
        }
    }
Exemple #20
0
    public static WorldStateProp Create(E_PropKey key, AgentHuman state)
    {
        WorldStateProp p = null;

        if (m_UnusedProps.Count > 0)
        {
            p          = m_UnusedProps.Dequeue();
            p.Agent    = state;
            p.PropType = E_PropType.Agent;
        }
        else
        {
            p = new WorldStateProp(state);
        }

        p.Time    = UnityEngine.Time.timeSinceLevelLoad;
        p.PropKey = key;
        return(p);
    }
Exemple #21
0
    public WeaponBase GetWeapon(AgentHuman Owner, E_WeaponID id)
    {
        // test if we have configured cache for this type of weapon...
        if (WeaponsCache.ContainsKey(id) == false)
        {
            Debug.LogError("WeaponManager: unknown type " + id);
            return(null);
        }

        // if we known this weapon type but we don't have resource cache than go out,
        // this is corect situation...
        else if (WeaponsCache[id] == null)
        {
            Debug.LogError("WeaponManager: For this type " + id + " we don't have resource");
            return(null);
        }

        else
        {
            GameObject go = WeaponsCache[id].Get();
            // assert if go is null... oops we don't have asserts...
            if (go)
            {
                WeaponBase weapon = go.GetComponent <WeaponBase>();

                if (null != weapon)
                {
                    weapon.Initialize(Owner, id);
                }
                else
                {
                    Debug.LogWarning("WeaponManager.GetWeapon() : weapon object without WeaponBase component - weapon '" + id + "'");
                }

                return(weapon);
            }
            else
            {
                return(null);
            }
        }
    }
    protected void Knockdown(E_MeleeType meleeType, uLink.NetworkViewID viewId, Vector3 direction)
    {
#if !DEADZONE_CLIENT
        if (Owner.IsServer)
        {
            ServerAnticheat.ReportPotentialCheatAttempt("Knockdown", "should never be called on the server side", Owner.NetworkView.owner);
            return;
        }
#endif

        if (Owner.BlackBoard.DontUpdate)
        {
            return;
        }

        uLink.NetworkView View     = (viewId != uLink.NetworkViewID.unassigned) ? uLink.NetworkView.Find(viewId) : null;
        AgentHuman        attacker = View ? View.GetComponent <AgentHuman>() : null;

        Owner.KnockDown(attacker, meleeType, direction);
    }
Exemple #23
0
    public AmmoBox GetNearestDroppedAmmoClip(AgentHuman agent, float dist)
    {
        float sqrDist = dist * dist;

        foreach (AmmoBox a in AmmoBoxes)
        {
            if (a.IsActive == false)
            {
                continue;
            }

            Vector3 pos = agent.CharacterController.ClosestPointOnBounds(a.Transform.position);

            if ((a.Transform.position - pos).sqrMagnitude < sqrDist)
            {
                return(a);
            }
        }

        return(null);
    }
Exemple #24
0
    /********************************************
    *			GETTERS/SETTERS
    ********************************************/

    public override float GetHeuristicDistance(AgentHuman ai, AStarNode aStarNode, bool firstRun)
    {
        //If we are on the first run then we know that we have no node so we need to setup the first node
        AStarGOAPNode node = (AStarGOAPNode)aStarNode;

        if (firstRun)
        {
            //Copy the WS satisfaction conditions to the nodes goal state
            node.GoalState.Reset();
            Goal.SetWSSatisfactionForPlanning(node.GoalState);
            Goal.ChangeCurrentWSForPlanning(node.CurrentState);
        }
        else
        {
            //Now we know that the node being checked is an action.
            //We need to get the action and apply it
            GOAPAction action = Map.GetAction(aStarNode.NodeID);
            //if(action.ValidateWSPreconditions(node.CurrentState,node.GoalState))
            {
                //if(action.ValidateWSEffects(ai,&node.CurrentState,&node.GoalState))
                {
                    //action.AddInvalidPreconditionsToGoal(ai,&node.CurrentState,&node.GoalState);
                    //action.ApplyWSEffects(ai,&node.CurrentState,&node.GoalState);
                    action.SolvePlanWSVariable(node.CurrentState, node.GoalState);
                    action.SetPlanWSPreconditions(node.GoalState);
                }
            }
        }

        //  if (Owner.debugGOAP) Debug.Log("GetHeuristicDistance1 : goal" + node.GoalState.ToString());
        //  if (Owner.debugGOAP) Debug.Log("GetHeuristicDistance1 : current" + node.CurrentState.ToString());

        MergeStates(ai, node.CurrentState, node.GoalState);

        //       if (Owner.debugGOAP) Debug.Log("GetHeuristicDistance2 : goal" + node.GoalState.ToString());
//        if (Owner.debugGOAP) Debug.Log("GetHeuristicDistance2 : current" + node.CurrentState.ToString());

        return(node.GoalState.GetNumWorldStateDifferences(node.CurrentState));
    }
Exemple #25
0
    public bool CanFire(AgentHuman agent)
    {
        if (agent.BlackBoard.CoverPose == E_CoverPose.Stand)
        {
            if (agent.BlackBoard.CoverPosition == E_CoverDirection.Middle)
            {
                return(false);
            }

            if (agent.BlackBoard.CoverPosition == E_CoverDirection.Left && CoverFlags.Get(Cover.E_CoverFlags.LeftStand) == false)
            {
                return(false);
            }

            if (agent.BlackBoard.CoverPosition == E_CoverDirection.Right && CoverFlags.Get(Cover.E_CoverFlags.RightStand) == false)
            {
                return(false);
            }
        }
        else
        {
            if (agent.BlackBoard.CoverPosition == E_CoverDirection.Middle && CoverFlags.Get(Cover.E_CoverFlags.UpCrouch) == false)
            {
                return(false);
            }

            if (agent.BlackBoard.CoverPosition == E_CoverDirection.Left && CoverFlags.Get(Cover.E_CoverFlags.LeftCrouch) == false)
            {
                return(false);
            }

            if (agent.BlackBoard.CoverPosition == E_CoverDirection.Right && CoverFlags.Get(Cover.E_CoverFlags.RightCrouch) == false)
            {
                return(false);
            }
        }

        return(true);
    }
Exemple #26
0
    //
    void AgentDetectedStateChanged(AgentHuman agent, bool detected)
    {
        //set new state on server
        agent.BlackBoard.IsDetected = detected;

        //inform connected clients
        Owner.NetworkView.RPC("AgentDetected", uLink.RPCMode.Others, Owner.NetworkView.viewID, agent.NetworkView.viewID, detected);

        if (detected)
        {
            //add buffered RPC for newly connected clients
            Owner.NetworkView.RPC("AgentDetected", uLink.RPCMode.Buffered, Owner.NetworkView.viewID, agent.NetworkView.viewID, true);
        }
        else
        {
            //RemoveRPCsByName smazne VSECKY RPC AgentDetected, tedy i pro agenty, kteri zustavaji detected. Nutno refreshnout cele pri nasledujici detekci.
            RefreshBufferedRPC = true;

            //find and remove the previously buffered RPC
            uLink.Network.RemoveRPCsByName(Owner.NetworkView.viewID, "AgentDetected");
        }
    }
Exemple #27
0
    public void OccupyPosition(E_CoverDirection position, AgentHuman agent)
    {
        AllAgents.AddUnique(agent);

        switch (position)
        {
        case E_CoverDirection.Left:
            LeftAgents.AddUnique(agent);
            return;

        case E_CoverDirection.Right:
            RightAgents.AddUnique(agent);
            return;

        case E_CoverDirection.Middle:
            MiddleAgents.AddUnique(agent);
            return;

        case E_CoverDirection.Unknown:

            if (IsLeftAllowed)
            {
                LeftAgents.AddUnique(agent);
            }

            if (IsRightAllowed)
            {
                RightAgents.AddUnique(agent);
            }

            if (IsMiddleAllowed)
            {
                MiddleAgents.AddUnique(agent);
            }

            break;
        }
    }
Exemple #28
0
    /*
     * Activate the GOAP plan
     */

    public bool Activate(AgentHuman ai, GOAPGoal goal)
    {
        /*if(ai.debugGOAP)
         * {
         * string s = this.ToString() + " - Activated for " + goal.ToString() + " do actions:";
         * for (int i = 0 ; i < m_Actions.Count ; i++)
         * s += " " + m_Actions[i].ToString();
         *
         * Debug.Log(Time.timeSinceLevelLoad + " " + s);
         * }*/

        if (m_Actions.Count == 0)
        {
            return(false);
        }

        //Get the first action
        CurrentStep = 0;

        //For the first action, first check if context preconditions are satisfied.
        GOAPAction a = CurrentAction;

        if (a != null)
        {
            if (a.ValidateContextPreconditions(ai.WorldState, false) == false)
            {
//Are the context preconditions validated????
                //if (Owner.debugGOAP) Debug.Log(Time.timeSinceLevelLoad + " " + this.ToString() + " - " + a.ToString() + " ValidateContextPreconditions failed !!");
                return(false);
            }

            a.Activate();
//			if(a.IsActionComplete())
//				AdvancePlan();
        }

        return(true);
    }
Exemple #29
0
    public void OnSceneGUI()
    {
        AgentDebugInfo debugInfo = target as AgentDebugInfo;
        AgentHuman     agent     = debugInfo.GetComponent <AgentHuman>();

        if (agent.BlackBoard.Desires.CoverNear.Cover)
        {
            Handles.color = Color.white;
            if (agent.BlackBoard.Desires.CoverNear.LeftCoverValidity > 0)
            {
                Handles.SphereCap(0, agent.BlackBoard.Desires.CoverNear.Cover.LeftEdge, agent.BlackBoard.Desires.CoverNear.Cover.Transform.rotation, 0.3f);
            }
            if (agent.BlackBoard.Desires.CoverNear.RightCoverValidity > 0)
            {
                Handles.SphereCap(0, agent.BlackBoard.Desires.CoverNear.Cover.RightEdge, agent.BlackBoard.Desires.CoverNear.Cover.Transform.rotation, 0.3f);
            }
            if (agent.BlackBoard.Desires.CoverNear.MiddleCoverValidity > 0)
            {
                Handles.SphereCap(0, agent.BlackBoard.Desires.CoverNear.Cover.Position, agent.BlackBoard.Desires.CoverNear.Cover.Transform.rotation, 0.3f);
            }
        }
        if (agent.BlackBoard.Desires.CoverSelected)
        {
            Handles.color = Color.green;
            if (agent.BlackBoard.Desires.CoverPosition == E_CoverDirection.Left)
            {
                Handles.SphereCap(0, agent.BlackBoard.Desires.CoverSelected.LeftEdge, agent.BlackBoard.Desires.CoverSelected.Transform.rotation, 0.32f);
            }
            else if (agent.BlackBoard.Desires.CoverPosition == E_CoverDirection.Right)
            {
                Handles.SphereCap(0, agent.BlackBoard.Desires.CoverSelected.RightEdge, agent.BlackBoard.Desires.CoverSelected.Transform.rotation, 0.32f);
            }
            else
            {
                Handles.SphereCap(0, agent.BlackBoard.Desires.CoverSelected.Position, agent.BlackBoard.Desires.CoverSelected.Transform.rotation, 0.32f);
            }
        }
    }
Exemple #30
0
    void ServerDistributePoint(E_ZoneControlEvent action, E_Team winner)
    {
        foreach (KeyValuePair <uLink.NetworkPlayer, ComponentPlayer> pair in Player.Players)
        {
            AgentHuman a = pair.Value.Owner;
            if (a.IsAlive == false)
            {
                continue;
            }

            if (a.Team != winner)
            {
                continue;
            }

            if ((Center - a.Position).sqrMagnitude > Range * Range)
            {
                continue;
            }

            PPIManager.Instance.ServerAddScoreForZoneControl(action, a.networkView.owner);
        }
    }