示例#1
0
 public override void PerformAction(PerformActionEvent actionEvent)
 {
     base.PerformAction(actionEvent);
     if (actionEvent.entity.tag == "Mob")
     {
         AIPath.target = actionEvent.entity.transform;
         ActionTransform = actionEvent.entity.transform;
     }
     else if (actionEvent.entity.tag == "Building")
     {
         AIPath.target = actionEvent.entity.transform;
         ActionTransform = actionEvent.entity.transform;
     }
 }
示例#2
0
 private void ActionSelected(MethodInfo mi, int index)
 {
     ToggleUI();                                                         // Hide UI
     enableInputs.Invoke(true);                                          // Enable inputs
     performEvent += () => { mi.Invoke(null, new object[] { packageInfo.UnitSelected, index, packageInfo.TargetTile }); };
     performEvent += () =>
     {
         AudioManager.Instance.InitializeRoutingAndPlay(AudioManager.Instance.genericClips, GV.channelID_ui, 1, GV.uiFX, false);
     };
     // Deselection
     InputManager.Instance.deselectEvent  = null;                        // Reset Event
     InputManager.Instance.deselectEvent += () =>
     {
         GridManager.aStar.Deselect();                                   // Set Unit null A*
         GridManager.realtimeOverlay.isEnabled = false;
         ResetEvent();                                                   // Set Perform Event to null since we deselect the action
         PlayerSelected(packageInfo.UnitSelected as PlayerUnit);
     };
 }
示例#3
0
 /// <summary>
 /// When called this method, using the actionEvent parameter will cause the Entity
 /// to trigger a response from the variables passed in. For example passing in an entity here
 /// with flags that are considered to be enemy flags from this entity, might cause this entity
 /// to move to and attack the entity associated with the actionEvent. This method is how ActiveEntities
 /// communicate with one another. Rather than having logic and references all stored and cached within multiple
 /// different entities this is used instead. PerformActionEvent being a struct also means it will be removed from 
 /// the stack when exiting the scope of the method call which has the added benefit of saving the initilization of
 /// otherwise useless objects on the heap.
 /// </summary>
 public virtual void PerformAction(PerformActionEvent actionEvent)
 {
 }
示例#4
0
 /// <summary>
 /// This method essentially calls PerformAction on another ActiveEntity from this current mob.
 /// Unlike accessing PerformAction directly this method takes into account the mobs action speed
 /// i.e how fast a mob can perform an action in succession.
 /// </summary>
 /// <param name="actionEvent"></param>
 public void TryPerformAction(PerformActionEvent actionEvent, ActiveEntity otherEntity)
 {
     if (Time.time - _lastActionTime > skills.actionSpeed)
     {
         _lastActionTime = Time.time;
         otherEntity.PerformAction(actionEvent);
     }
 }
示例#5
0
    public override void PerformAction(PerformActionEvent actionEvent)
    {
        base.PerformAction(actionEvent);

        // Avoid trying to set commands on self
        if (actionEvent.entity == this)
            return;
        switch (actionEvent.tag)
        {
            case "Ground":
                CurrentActivity = ActivityState.None;
                AIPath.targetCoord = actionEvent.vector3Args[0];
                break;
            case "Mob":
                if (IsEnemey(actionEvent.entity.FactionFlags))
                {
                    // The action is an enemy. Set mode to attacking and move to position
                    // Note that the pathfinding AI determains the attack distance before attacking events are fired
                    CurrentActivity = ActivityState.Attacking;
                    SetEntityAndFollow(actionEvent.entity);
                }
                break;
            case "Building":
                if (IsEnemey(actionEvent.entity.FactionFlags))
                {
                    CurrentActivity = ActivityState.Attacking;
                    SetEntityAndFollow(actionEvent.entity);
                }
                break;
            case "BluePrint":
                if (!IsEnemey(actionEvent.entity.FactionFlags) && (MobAbiltiyFlags & MobFlags.CanBuild) == MobFlags.CanBuild)
                {
                    CurrentActivity = ActivityState.Building;
                    SetEntityAndFollow(actionEvent.entity);
                }
                break;
            case "Tree":
                if ((MobAbiltiyFlags & MobFlags.CanWoodcut) == MobFlags.CanWoodcut)
                {
                    CurrentActivity = ActivityState.Woodcutting;
                    SetEntityAndFollow(actionEvent.entity);
                }
                break;
        }
    }
示例#6
0
 public override void PerformAction(PerformActionEvent actionEvent)
 {
     base.PerformAction(actionEvent);
     switch (actionEvent.tag)
     {
         case "Mob":
             // Harvest the resource for the calling mob
             // int parameter passed in should specify the amount required
             HarvestResource(actionEvent.entity.GetComponent<Mob>().Resource, actionEvent.intArgs[0]);
             break;
     }
 }
示例#7
0
 private void ResetEvent()
 {
     performEvent = null;
     InputManager.Instance.deselectEvent = null;
 }
 public override void PerformAction(PerformActionEvent actionEvent)
 {
     if (actionEvent.tag == "Mob")
     {
         Mob mob = actionEvent.entity.GetComponent<Mob>();
         // If the mob can build, build
         if ((mob.MobAbiltiyFlags & Mob.MobFlags.CanBuild) == Mob.MobFlags.CanBuild)
             Construct(mob.Skills.buildPower);
     }
 }