Ejemplo n.º 1
0
 public override ActionResult Fire(IntelligenceController controller)
 {
     var h = controller.Owner as Human;
     if (!h) return ActionResult.Failed;
     h.SetGlowColor(color);
     return ActionResult.Success;
 }
Ejemplo n.º 2
0
 public override ActionResult Fire(IntelligenceController controller)
 {
     Vector3 pos;
     if (posVarSource == PositionSource.Self)
     {
         pos = controller.Owner.transform.position;
     }
     else
     {
         if (posVarName.Length < 1) { return ActionResult.Failed; }
         if (!controller.GetMemoryValue(posVarName, out pos))
         {
             Entity e;
             if (!controller.GetMemoryValue(posVarName, out e))
             {
                 return ActionResult.Failed;
             }
             pos = e.transform.position;
         }
     }
     FungusNode node = GameWorld.Instance.SpawnFungusNode(pos);
     if (saveAsVar)
     {
         if (saveVarName.Length > 0)
         {
             controller.SetMemoryValue(saveVarName, node);
             return ActionResult.Success;
         }
         return ActionResult.Failed;
     }
     return ActionResult.Success;
 }
Ejemplo n.º 3
0
 public override ActionResult Run(IntelligenceController controller, float deltaTime)
 {
     PatrolPath path = null;
     if (controller.GetMemoryValue(Intelligence.SpecialPathIdentifier, out path))
     {
         int currentIndex = 0;
         if (!controller.GetMemoryValue(Intelligence.SpecialPathIndexIdentifier, out currentIndex))
         {
             controller.SetMemoryValue(Intelligence.SpecialPathIndexIdentifier, 0);
         }
         EntityMover.MoveResult result = controller.Owner.MoveTo(path.points[currentIndex].position);
         if (result == EntityMover.MoveResult.ReachedTarget)
         {
             currentIndex++;
             if (currentIndex >= path.points.Count)
             {
                 currentIndex = 0;
                 controller.SetMemoryValue(Intelligence.SpecialPathIndexIdentifier, 0);
                 return ActionResult.Success;
             }
             controller.SetMemoryValue(Intelligence.SpecialPathIndexIdentifier, currentIndex);
         }
         return ActionResult.Running;
     }
     return ActionResult.Failed;
 }
Ejemplo n.º 4
0
 public override ActionResult Fire(IntelligenceController controller)
 {
     Message m = new Message(controller.Owner, type, Vector3.zero);
     if (positionVariableName.Length > 0)
     {
         if (!controller.GetMemoryValue(positionVariableName, out m.position))
         {
             Entity e = null;
             if (!controller.GetMemoryValue(positionVariableName, out e))
             {
                 return ActionResult.Failed;
             }
             m.position = e.transform.position;
         }
     }
     switch (target)
     {
         case MessageTarget.Humans:
             GameWorld.Instance.BroadcastToHumans(m, controller.Owner.transform.position, radius);
             break;
         case MessageTarget.Fungi:
             GameWorld.Instance.BroadcastToNodes(m, controller.Owner.transform.position, radius);
             break;
         case MessageTarget.PoliceStations:
             GameWorld.Instance.BroadcastToPoliceStations(m, controller.Owner.transform.position, radius);
             break;
     }
     return ActionResult.Success;
 }
Ejemplo n.º 5
0
 public override ActionResult Fire(IntelligenceController controller)
 {
     var h = controller.Owner as Human;
     if (!h) return ActionResult.Failed;
     h.EnableSlimeComponents();
     return ActionResult.Success;
 }
Ejemplo n.º 6
0
 public void OnUpdate(IntelligenceController controller, float deltaTime)
 {
     for (int i = 0; i < updateActions.Count; i++)
     {
         updateActions[i].Run(controller, deltaTime);
     }
 }
Ejemplo n.º 7
0
 public void OnExit(IntelligenceController controller)
 {
     for (int i = 0; i < exitActions.Count; i++)
     {
         exitActions[i].Fire(controller);
     }
 }
Ejemplo n.º 8
0
 public override ActionResult Run(IntelligenceController controller, float deltaTime)
 {
     Vector3 target = controller.Owner.transform.position;
     if (controller.GetMemoryValue(storeName, out target))
     {
         EntityMover.MoveResult res = controller.Owner.MoveTo(target);
         if (res == EntityMover.MoveResult.ReachedTarget)
         {
             return ActionResult.Success;
         }
         if (res == EntityMover.MoveResult.TargetNotReachable)
         {
             return ActionResult.Failed;
         }
     }
     else
     {
         Entity t = controller.Owner;
         if (controller.GetMemoryValue(storeName, out t))
         {
             EntityMover.MoveResult res = controller.Owner.MoveTo(t.transform.position);
             if (res == EntityMover.MoveResult.ReachedTarget)
             {
                 return ActionResult.Success;
             }
             if (res == EntityMover.MoveResult.TargetNotReachable)
             {
                 return ActionResult.Failed;
             }
         }
     }
     return ActionResult.Running;
 }
Ejemplo n.º 9
0
 public override ActionResult Fire(IntelligenceController controller)
 {
     Entity t = null;
     switch (Type)
     {
         case TargetType.Human:
             t = GameWorld.Instance.GetNearestHuman(controller.Owner.transform.position, targetClassification);
             break;
         case TargetType.Fungus:
             t = GameWorld.Instance.GetNearestFungusNode(controller.Owner.transform.position);
             break;
         case TargetType.PoliceStation:
             t = GameWorld.Instance.GetNearestPoliceStation(controller.Owner.transform.position);
             break;
     }
     if (t && Mathf.Sqrt(AstarMath.SqrMagnitudeXZ(controller.Owner.transform.position, t.transform.position)) <= range)
     {
         if (checkLOS && !GameWorld.Instance.HasLineOfSight(controller.Owner, t))
         {
             return ActionResult.Failed;
         }
         if (saveVar)
         {
             controller.SetMemoryValue(storageVar, t);
         }
         return ActionResult.Success;
     }
     return ActionResult.Failed;
 }
Ejemplo n.º 10
0
 public override ActionResult Fire(IntelligenceController controller)
 {
     object var;
     if (controller.GetMemoryValue (varName, out var)) {
         Debug.Log (var.ToString ());
     }
     return ActionResult.Success;
 }
Ejemplo n.º 11
0
 public override ActionResult Fire(IntelligenceController controller)
 {
     if (newBehaviour && controller.Owner.SetBehaviour(newBehaviour))
     {
         return ActionResult.Success;
     }
     return ActionResult.Failed;
 }
Ejemplo n.º 12
0
 public override ActionResult Fire(IntelligenceController controller)
 {
     if (controller.Owner.PlaySound(type))
     {
         return ActionResult.Success;
     }
     return ActionResult.Failed;
 }
Ejemplo n.º 13
0
 public override ActionResult Fire(IntelligenceController controller)
 {
     var modID = controller.Owner.ApplySpeedMod(type, controller.Owner, timeout);
     if (saveAsVar)
     {
         controller.SetMemoryValue(varName, modID);
     }
     return ActionResult.Success;
 }
Ejemplo n.º 14
0
 public override ActionResult Fire(IntelligenceController controller)
 {
     object o;
     if (controller.GetMemoryValue(varName, out o))
     {
         return ActionResult.Success;
     }
     return ActionResult.Failed;
 }
Ejemplo n.º 15
0
 public override ActionResult Fire(IntelligenceController controller)
 {
     int id;
     if (controller.GetMemoryValue(varName, out id))
     {
         controller.Owner.RevokeSpeedMod(id);
         return ActionResult.Success;
     }
     return ActionResult.Failed;
 }
Ejemplo n.º 16
0
 public override ActionResult Fire(IntelligenceController controller)
 {
     if (newState) {
         if (controller.IsActiveState (newState.name)) {
             return ActionResult.Success;
         }
         controller.ChangeState (newState);
         return ActionResult.Success;
     }
     return ActionResult.Failed;
 }
Ejemplo n.º 17
0
 public override ActionResult Fire(IntelligenceController controller)
 {
     Entity t = null;
     if (controller.GetMemoryValue(entityVarName, out t) && t != null)
     {
         if (Mathf.Sqrt(AstarMath.SqrMagnitudeXZ(controller.Owner.transform.position, t.transform.position)) < range)
         {
             return ActionResult.Success;
         }
     }
     return ActionResult.Failed;
 }
Ejemplo n.º 18
0
 public override ActionResult Run(IntelligenceController controller, float deltaTime)
 {
     if (Time.time-lastRun >= interval)
     {
         lastRun = Time.time;
         if (controller.Owner.PlaySound(type))
         {
             return ActionResult.Success;
         }
         return ActionResult.Failed;
     }
     return ActionResult.Running;
 }
Ejemplo n.º 19
0
 public override ActionResult Run(IntelligenceController controller, float deltaTime)
 {
     if (Time.time - lastAttack > interval)
     {
         lastAttack = Time.time;
         Entity target;
         if (controller.GetMemoryValue(entityVarName, out target))
         {
             if (!target.isAttackable) { return ActionResult.Failed; }
             target.Damage(controller.Owner, damagePerAttack);
             controller.Owner.TriggerAnimator("Attack");
             return ActionResult.Success;
         }
     }
     return ActionResult.Running;
 }
Ejemplo n.º 20
0
 public override ActionResult Fire(IntelligenceController controller)
 {
     if (varName.Length < 1) { return ActionResult.Failed; }
     if (target == TargetType.Self)
     {
         controller.SetMemoryValue(varName, controller.Owner.transform.position);
         return ActionResult.Success;
     }
     Entity e;
     if (controller.GetMemoryValue(targetVarName, out e))
     {
         controller.SetMemoryValue(varName, e.transform.position);
         return ActionResult.Success;
     }
     return ActionResult.Failed;
 }
Ejemplo n.º 21
0
 public override ActionResult Fire(IntelligenceController controller, object value = null)
 {
     Message m = value as Message;
     if (m == null) { return ActionResult.Failed; }
     if (m.type != handledType) { return ActionResult.Failed; }
     if (savePosition)
     {
         controller.SetMemoryValue(varName, m.position);
     }
     if (saveSender)
     {
         controller.SetMemoryValue(senderVarName, m.sender);
     }
     if (action)
     {
         action.Fire(controller, value);
     }
     return ActionResult.Success;
 }
Ejemplo n.º 22
0
 public override ActionResult Fire(IntelligenceController controller)
 {
     Entity e;
     if (controller.GetMemoryValue(targetName, out e))
     {
         switch (paramType)
         {
             case ParameterType.None:
                 if (e.TriggerBehaviour(triggerName))
                 {
                     return ActionResult.Success;
                 }
                 return ActionResult.Failed;
             case ParameterType.Self:
                 if (e.TriggerBehaviour(triggerName, controller.Owner))
                 {
                     return ActionResult.Success;
                 }
                 return ActionResult.Failed;
             case ParameterType.VarValue:
                 object value;
                 if (controller.GetMemoryValue(paramTypeValue, out value))
                 {
                     if (e.TriggerBehaviour(triggerName, value))
                     {
                         return ActionResult.Success;
                     }
                 }
                 return ActionResult.Failed;
             case ParameterType.String:
                 if (e.TriggerBehaviour(triggerName, paramTypeValue))
                 {
                     return ActionResult.Success;
                 }
                 return ActionResult.Failed;
         }
     }
     return ActionResult.Failed;
 }
Ejemplo n.º 23
0
 public override ActionResult Run(IntelligenceController controller, float deltaTime)
 {
     Vector3 fleeSource;
     if (!controller.GetMemoryValue(fleeFrom, out fleeSource))
     {
         Entity e;
         if (!controller.GetMemoryValue(fleeFrom, out e))
         {
             return ActionResult.Failed;
         }
         fleeSource = e.transform.position;
     }
     EntityMover.MoveResult res = controller.Owner.FleeFrom(fleeSource);
     if (res == EntityMover.MoveResult.ReachedTarget || res == EntityMover.MoveResult.TargetNotReachable)
     {
         return ActionResult.Success;
     }
     if (Vector3.SqrMagnitude(controller.Owner.transform.position - fleeSource) >= desiredDistance * desiredDistance)
     {
         return ActionResult.Success;
     }
     return ActionResult.Running;
 }
Ejemplo n.º 24
0
 public override ActionResult Fire(IntelligenceController controller)
 {
     if (methodName.Length > 1)
     {
         Entity e;
         if (useTargetVar)
         {
             controller.GetMemoryValue(targetVarName, out e);
         }
         else
         {
             e = controller.Owner;
         }
         if (!e) { return ActionResult.Failed; }
         switch (paramType)
         {
             case ParameterType.None:
                 e.BroadcastMessage(methodName);
                 return ActionResult.Success;
             case ParameterType.Self:
                 e.BroadcastMessage(methodName, controller.Owner);
                 return ActionResult.Success;
             case ParameterType.VarValue:
                 object value;
                 if (controller.GetMemoryValue(paramTypeValue, out value))
                 {
                     e.BroadcastMessage(methodName, value);
                     return ActionResult.Success;
                 }
                 return ActionResult.Failed;
             case ParameterType.String:
                 e.BroadcastMessage(methodName, paramTypeValue);
                 return ActionResult.Success;
         }
     }
     return ActionResult.Failed;
 }
Ejemplo n.º 25
0
 public override ActionResult Fire(IntelligenceController controller)
 {
     controller.Owner.RevokeAllSpeedMods(controller.Owner);
     return ActionResult.Success;
 }
Ejemplo n.º 26
0
 public override ActionResult Run(IntelligenceController controller, float deltaTime)
 {
     return Fire(controller);
 }
Ejemplo n.º 27
0
 public override ActionResult Run(IntelligenceController controller, float deltaTime)
 {
     repeated = false;
     REPEAT:
     if (currentWaitTime > 0) { currentWaitTime = UnityEngine.Mathf.Clamp(currentWaitTime - deltaTime, 0, currentWaitTime); return ActionResult.Running; }
     PatrolPath path = null;
     if (controller.GetMemoryValue(Intelligence.PathIdentifier, out path))
     {
         int currentIndex = 0;
         if (!controller.GetMemoryValue(Intelligence.PathIndexIdentifier, out currentIndex))
         {
             controller.SetMemoryValue(Intelligence.PathIndexIdentifier, 0);
         }
         PatrolPath.PatrolPoint currentPoint = path.points[currentIndex];
         EntityMover.MoveResult result = controller.Owner.MoveTo(currentPoint.position);
         if (result == EntityMover.MoveResult.ReachedTarget)
         {
             if (!ignorePathConfiguration)
             {
                 switch (currentPoint.action)
                 {
                     case PatrolPath.PatrolPointActions.Wait:
                         currentWaitTime = currentPoint.waitTime;
                         break;
                     case PatrolPath.PatrolPointActions.ChangePath:
                         if (UnityEngine.Random.Range(0, 100) > currentPoint.actionProbability) { break; }
                         PatrolPath linkedPath = currentPoint.linkedPath;
                         if (linkedPath != null)
                         {
                             controller.LoadPath(linkedPath);
                             controller.SetMemoryValue(Intelligence.PathIndexIdentifier, linkedPath.GetNearestPatrolPointIndex(controller.Owner.transform.position));
                             return ActionResult.Running;
                         }
                         break;
                     case PatrolPath.PatrolPointActions.ExecuteFunction:
                         if (UnityEngine.Random.Range(0, 100) > currentPoint.actionProbability) { break; }
                         switch (currentPoint.target)
                         {
                             case PatrolPath.PatrolPoint.FunctionTarget.NPC:
                                 controller.Owner.BroadcastMessage(currentPoint.functionName, UnityEngine.SendMessageOptions.RequireReceiver);
                                 break;
                             case PatrolPath.PatrolPoint.FunctionTarget.PatrolPath:
                                 path.BroadcastMessage(currentPoint.functionName, UnityEngine.SendMessageOptions.RequireReceiver);
                                 break;
                         }
                         break;
                 }
             }
             currentIndex++;
             if (currentIndex >= path.points.Count)
             {
                 currentIndex = 0;
             }
             controller.SetMemoryValue(Intelligence.PathIndexIdentifier, currentIndex);
             if (!repeated)
             {
                 repeated = true;
                 goto REPEAT;
             }
         }
         return ActionResult.Running;
     }
     return ActionResult.Failed;
 }
Ejemplo n.º 28
0
 public override ActionResult Fire(IntelligenceController controller)
 {
     controller.SetMemoryValue(varName, null);
     return ActionResult.Success;
 }
Ejemplo n.º 29
0
 public override ActionResult Fire(IntelligenceController controller)
 {
     controller.Owner.TriggerAnimator(triggerID);
     return ActionResult.Success;
 }
Ejemplo n.º 30
0
 public override ActionResult Fire(IntelligenceController controller)
 {
     controller.Owner.Kill(controller.Owner);
     return ActionResult.Success;
 }