Пример #1
0
 public ActionData(TheAction action, List <T> list, T item, T oldItem, int position, int oldPosition)
     : this(action, list,
            item, oldItem,
            position, oldPosition,
            -1, -1, false)
 {
 }
Пример #2
0
 public XElement GetXml()
 {
     return(new XElement("TriggeredAction",
                         TheTrigger.GetXml(),
                         TheAction?.GetXml()
                         ));
 }
Пример #3
0
        public void Dispose()
        {
            ParentProfile = null;

            TheTrigger.Delete();
            TheAction?.Delete();
        }
Пример #4
0
 public ActionData(TheAction action, T item)
     : this(action, null,
            item, null,
            -1, -1,
            -1, -1, false)
 {
 }
Пример #5
0
        public void TraceEvent(TheAction ac, IWorldObject trigger)
        {
            switch (ac)
            {
            case TheAction.Attack:
                if (trigger is IPlayer p)
                {
                    Source.TraceEvent(TraceEventType.Critical, MessageId++, $"Player {p.Display} dealt {p.DmgStrategy.AmountOfDmg(p)} dmg");
                }
                break;

            case TheAction.Move:
                if (trigger is IPlayer p1)
                {
                    Source.TraceEvent(TraceEventType.Critical, MessageId++, $"Player {p1.Display} Moved to X: {p1.Pos.X}, Y: {p1.Pos.Y}");
                }
                break;

            case TheAction.Pickup:
                if (trigger is Weapon w)
                {
                    Source.TraceEvent(TraceEventType.Critical, MessageId++, $"Weapon was picked up at X: {w.Pos.X}, Y: {w.Pos.Y}");
                }
                break;
            }
        }
Пример #6
0
        public override string ToString()
        {
            string output = ((TheAction is CGActionWave) ? "PLAY " : "DO ") + TheAction.ToString();

            output += " WHEN " + TheTrigger.ToString();

            return(output);
        }
Пример #7
0
 public ActionData(TheAction action, List <T> list, T item, T oldItem, int position, int oldPosition, int index, int indexPivot, bool isIncluded)
 {
     TheAction   = action;
     Item        = item;
     OldItem     = oldItem;
     Position    = position;
     OldPosition = oldPosition;
     List        = list;
     Index       = index;
     IndexPivot  = indexPivot;
     IsIncluded  = isIncluded;
 }
Пример #8
0
 void OnTriggerFire(Object sender, RotationEventArgs e)
 {
     TheAction?.Run();
 }
 // constructor
 public Timer(int seconds, TheAction action)
 {
     this.IntervalSeconds = seconds;
     this.action          = action;
 }
Пример #10
0
    void Awake()
    {
        //this determines what team they are on and then sets thier home base depending on this
        if (this.CompareTag("Blue Team"))
        {
            HomeBase = GameObject.FindGameObjectWithTag("BlueBase");
        }
        else
        {
            HomeBase = GameObject.FindGameObjectWithTag("RedBase");
        }


        ///////////////////////////////////////////
        //goal One go get Flag and Bring it back//
        Goals GoPickUpFlag = new Goals(AIGoals.CaptureFlag, 0.0f, 10.0f, 0.0f, Valuefunctions);

        //actions included within the first goal
        CaptureFlagMove = new TheAction(TheActions, "MoveEnemySide", true, true, 0.0f, true);
        CaptureFlagMove.SetGoalSatisfaction(AIGoals.CaptureFlag, 1);

        CaptureFlagAttack = new TheAction(TheActions, "Attack", false, true, 0.0f, false);
        CaptureFlagAttack.SetGoalSatisfaction(AIGoals.attack, 2);

        CaptureFlagPickUp = new TheAction(TheActions, "PickUpFlag", true, true, 0.0f, false);
        CaptureFlagPickUp.SetGoalSatisfaction(AIGoals.CaptureFlag, 3);

        CaptrueFlagMoveHome = new TheAction(TheActions, "MoveHome", true, true, 0.0f, false);
        CaptrueFlagMoveHome.SetGoalSatisfaction(AIGoals.CaptureFlag, 4);

        CaptureFlagDropFlag = new TheAction(TheActions, "DropFlag", true, true, 0.0f, false);
        CaptureFlagDropFlag.SetGoalSatisfaction(AIGoals.CaptureFlag, 5);


        //the actions sequence for the first goal
        ActionSequence Sequence = new ActionSequence();

        Sequence.AddAction(CaptureFlagMove);
        Sequence.AddAction(CaptureFlagAttack);
        Sequence.AddAction(CaptureFlagPickUp);
        Sequence.AddAction(CaptrueFlagMoveHome);
        Sequence.AddAction(CaptureFlagDropFlag);
        Sequence.SetGoalSatisfaction(AIGoals.CaptureFlag, 5);
        //////////////////////////////////////////////////////////



        /////////////////////////////////////////////////
        //goal two protect the team mate with the flag//
        Goals ProtectTeamMate = new Goals(AIGoals.ProtectFriend, 0.0f, 1.0f, 0.0f, Valuefunctions);

        // the unique actions for the second goal
        ProtectTeamMateAction = new TheAction(TheActions, "ProtectTeamMateWithFlag", true, true, 0.0f, true);
        ProtectTeamMateAction.SetGoalSatisfaction(AIGoals.ProtectFriend, 1);

        AttackEnemy = new TheAction(TheActions, "Attack", false, true, 0.0f, false);
        AttackEnemy.SetGoalSatisfaction(AIGoals.ProtectFriend, 1);

        // the action sequence for the second goal
        ActionSequence Sequence2 = new ActionSequence();

        Sequence2.AddAction(ProtectTeamMateAction);
        Sequence2.AddAction(AttackEnemy);
        Sequence2.SetGoalSatisfaction(AIGoals.ProtectFriend, 5);
        ////////////////////////////////////////////////////////


        ///////////////////////////////////////////////////////
        //goal to guard the base once you have the enemy flag//
        Goals GuardBase = new Goals(AIGoals.Guard, 0, 5, 0, Valuefunctions);

        //the actions unique included within the third goal
        GuardTheBase = new TheAction(TheActions, "Guard", true, true, 0.0f, true);
        GuardTheBase.SetGoalSatisfaction(AIGoals.Guard, 1);

        AttackEnemyAtBase = new TheAction(TheActions, "Attack", true, true, 0.0f, false);
        AttackEnemyAtBase.SetGoalSatisfaction(AIGoals.Guard, 1);


        //the action sequence for the third goal
        ActionSequence Sequence3 = new ActionSequence();

        Sequence3.AddAction(GuardTheBase);
        Sequence3.AddAction(AttackEnemyAtBase);
        Sequence3.SetGoalSatisfaction(AIGoals.Guard, 5);
        //////////////////////////////////////////////////


        //////////////////////////////////////
        //goal four to flee and find health//
        Goals FleeAndGetHealth = new Goals(AIGoals.retreat, 0, 10, 0, Valuefunctions);

        // the actions that are needed for the fourth goal
        RetreatToSaftey = new TheAction(TheActions, "Flee", false, false, 0.0f, true);
        RetreatToSaftey.SetGoalSatisfaction(AIGoals.retreat, 5);

        HealHealth = new TheAction(TheActions, "Heal", false, false, 0.0f, true);
        HealHealth.SetGoalSatisfaction(AIGoals.retreat, 5);

        ActionSequence Sequence4 = new ActionSequence();

        Sequence4.AddAction(RetreatToSaftey);
        //Sequence4.AddAction(HealHealth);
        Sequence4.SetGoalSatisfaction(AIGoals.retreat, 10);
        ///////////////////////////////////////////////////

        /////////////////////////////////////////
        //goal five to get back thier own flag//
        Goals RetriveFlag = new Goals(AIGoals.Retrive, 0, 10, 0, Valuefunctions);

        // The actions that are needed for the fifth action
        GetFlagMoveToEnemySide = new TheAction(TheActions, "MoveEnemySide", false, true, 0, true);
        GetFlagMoveToEnemySide.SetGoalSatisfaction(AIGoals.Retrive, 3);

        GetFlagRetrieveFlag = new TheAction(TheActions, "RetrieveFriendlyFlag", false, false, 0.0f, false);
        GetFlagRetrieveFlag.SetGoalSatisfaction(AIGoals.Retrive, 4);

        GetFlagDrop = new TheAction(TheActions, "DropFlag", false, true, 0, false);
        GetFlagDrop.SetGoalSatisfaction(AIGoals.Retrive, 3);

        GetFlagAttack = new TheAction(TheActions, "Attack", false, true, 0, false);
        GetFlagAttack.SetGoalSatisfaction(AIGoals.Retrive, 2);

        GetFlagMoveHome = new TheAction(TheActions, "MoveHomeWithFriendlyFlag", false, true, 0, false);
        GetFlagMoveHome.SetGoalSatisfaction(AIGoals.Retrive, 2);

        ActionSequence Sequence5 = new ActionSequence();

        Sequence5.AddAction(GetFlagMoveToEnemySide);
        Sequence5.AddAction(GetFlagRetrieveFlag);
        Sequence5.AddAction(GetFlagAttack);
        Sequence5.AddAction(GetFlagMoveHome);
        Sequence5.AddAction(GetFlagDrop);

        Sequence5.SetGoalSatisfaction(AIGoals.Retrive, 10);
        /////////////////////////////////////////////////////

        //Goal Six to pick up power Up//

        Goals GetPowerUp = new Goals(AIGoals.PowerUp, 0, 10, 0, Valuefunctions);


        PickUpPowerUp = new TheAction(TheActions, "GetPowerUp", true, true, 0, false);
        PickUpPowerUp.SetGoalSatisfaction(AIGoals.PowerUp, 2);
        /////////////////////////////////////////////////////

        ActionSequence Sequence6 = new ActionSequence();

        Sequence6.AddAction(PickUpPowerUp);
        Sequence6.SetGoalSatisfaction(AIGoals.PowerUp, 10);


        //adding the goals and actions to the AI
        TheAI.AddGoal(GoPickUpFlag);
        TheAI.AddAction(Sequence);
        TheAI.AddGoal(ProtectTeamMate);
        TheAI.AddAction(Sequence2);
        TheAI.AddGoal(GuardBase);
        TheAI.AddAction(Sequence3);
        TheAI.AddGoal(FleeAndGetHealth);
        TheAI.AddAction(Sequence4);
        TheAI.AddGoal(RetriveFlag);
        TheAI.AddAction(Sequence5);
        TheAI.AddGoal(GetPowerUp);
        TheAI.AddAction(Sequence6);
    }
Пример #11
0
 //sets what action it is currently using
 public void SetCurrentAction(TheAction Action)
 {
     CurrentAction = Action;
 }
Пример #12
0
 //adds an action to the list
 public void AddAction(TheAction action)
 {
     actionlist.Add(action);
 }