Ejemplo n.º 1
0
 public override void Init(Fighter player, AIFighter fighter, FighterRoutine routine)
 {
     base.Init(player, fighter, routine);
     //m_lastObservable = 0;
     //m_observer = Fighter.gameObject.GetComponent<Observer> ();
     m_attackable = Fighter.GetComponent <Attackable> ();
 }
Ejemplo n.º 2
0
 public StayInRange(AIFighter fighter, int minRange, int maxRange, bool los)
     : base(fighter)
 {
     MinRange = minRange;
     MaxRange = maxRange;
     LoS      = los;
 }
Ejemplo n.º 3
0
    void CollectAndInitializeFighters()
    {
        m_aiFighters = new List <AIFighter>();
        foreach (BasicMovement fighterObj in Object.FindObjectsOfType <BasicMovement>())
        {
            // Add Fighters that are not the current player
            if (fighterObj.IsCurrentPlayer)
            {
                m_player = fighterObj.GetComponent <Fighter>();
                continue;
            }

            // Collect fighter components of relevance
            AIFighter fighterInfo = new AIFighter();
            fighterInfo.BasicMove  = fighterObj;
            fighterInfo.Fighter    = fighterObj.GetComponent <Fighter>();
            fighterInfo.Attackable = fighterObj.GetComponent <Attackable>();
            fighterInfo.Routine    = fighterObj.GetComponentInChildren <FighterRoutine>();
            // Catalog fighter
            m_aiFighters.Add(fighterInfo);
        }

        foreach (AIFighter fighter in m_aiFighters)
        {
            fighter.Routine.Init(m_player, fighter);
        }
    }
Ejemplo n.º 4
0
 protected AIAction(AIFighter fighter)
 {
     Fighter = fighter;
     Fight   = Fighter.Fight;
     Map     = Fight.Map;
     State   = AIActionState.INITIALIZE;
 }
Ejemplo n.º 5
0
        public SpellSelector(AIFighter fighter, EnvironmentAnalyser environment)
        {
            this.m_environment = environment;
            this.Fighter       = fighter;
            this.Possibilities = new System.Collections.Generic.List <SpellCastInformations>();
            this.Priorities    = new System.Collections.Generic.Dictionary <SpellCategory, int>
            {
                {
                    SpellCategory.Summoning,
                    5
                },

                {
                    SpellCategory.Buff,
                    4
                },

                {
                    SpellCategory.Damages,
                    3
                },

                {
                    SpellCategory.Healing,
                    2
                },

                {
                    SpellCategory.Curse,
                    1
                }
            };
        }
Ejemplo n.º 6
0
 public void Init(Fighter player, AIFighter fighter)
 {
     foreach (FighterTask task in Tasks)
     {
         task.Init(player, fighter);
     }
 }
        public void Handling_Fight_Event_Distance_Medium_Attack_Type_Punch()
        {
            // make sure that in the event both the distance and the attack type are close the
            // resut will be that of a close and close respons

            //arrange
            AIFighter    attacker = new AIFighter(1);
            NonAIFighter defender = new NonAIFighter(1, false, false);

            IGameWorld gw = new GameWorld();

            //set up
            gw.Distance     = "Medium";
            attacker.Attack = new Punch();

            String expected = "AI-Fighter <<Punch>> Non-AI-Fighter <<MISSED>>";



            //act
            string actual = gw.wAttack(attacker, defender, attacker.Attack);

            //assert

            Assert.AreEqual(expected, actual, " the correct attack result was returned");
        }
Ejemplo n.º 8
0
        //+++++++++++++++++++++++++++++New Code++++++++++++++++++++++++++++++++++
        /// <summary>
        /// Create an action node which is Punch attack type.
        /// modified Do (action) Node.
        /// </summary>
        /// <param name="context">The context.</param>
        /// <param name="AI">The ai.</param>
        /// <param name="NAI">The nai.</param>
        /// <returns></returns>
        /// <exception cref="System.ApplicationException">Can't create an unnested ActionNode, it must be a leaf node.</exception>
        public MyTreeBuilder Punch(GameWorld context, AIFighter AI, NonAIFighter NAI)
        {
            if (parentNodeStack.Count <= 0)
            {
                throw new ApplicationException("Can't create an unnested ActionNode, it must be a leaf node.");
            }

            Func <MyTimeData, MyBehaviourTreeStatus> fr;

            fr = t =>
            {
                // A Punch Attack
                Punch punch = new Punch();

                GameWorld gw = context;
                gw.wAttack(AI, NAI, punch);

                gw.ListOfEvents.Add("Punch non AI player");
                return(MyBehaviourTreeStatus.Success);
            };

            var actionNone = new ActionNode("Punch", fr);

            parentNodeStack.Peek().AddChild(actionNone);
            return(this);
        }/// <summary>
Ejemplo n.º 9
0
 public SpellCastAction(AIFighter fighter, Spell spell, Cell target, bool multipleCast)
     : base(fighter)
 {
     Spell        = spell;
     Target       = target;
     MultipleCast = multipleCast;
 }
Ejemplo n.º 10
0
 public EnvironmentAnalyser(AIFighter fighter)
 {
     Fighter = fighter;
     CellInformationProvider  = new AIFightCellsInformationProvider(Fighter.Fight, Fighter);
     Pathfinding              = new Pathfinder(CellInformationProvider);
     fighter.PositionChanged += OnPositionChanged;
 }
        public void Handling_Fight_Event_Distance_Close_Attack_Type_Special()
        {
            // make sure that in the event both the distance and the attack type are close the
            // resut will be that of a close and close respons

            //arrange
            AIFighter    attacker = new AIFighter(1);
            NonAIFighter defender = new NonAIFighter(1, false, false);

            IGameWorld gw = new GameWorld();

            //set up
            gw.Distance     = "Close";
            attacker.Attack = new Special();

            String expected = "Close Damage: AI-Fighter <<Special Move>> Non-AI-Fighter <<For>> <-30>";



            //act
            string actual = gw.wAttack(attacker, defender, attacker.Attack);

            //assert

            Assert.AreEqual(expected, actual, " the correct attack result was returned");
        }
Ejemplo n.º 12
0
 public void Init(Fighter player, AIFighter fighter)
 {
     m_tasks = new List <FighterTask> (GetComponents <FighterTask> ());
     //Debug.Log ("Initializing Routine for fighter: " + fighter);
     foreach (FighterTask task in m_tasks)
     {
         //Debug.Log ("init: " + task);
         task.Init(player, fighter, this);
     }
     //Debug.Log (m_tasks.Count);
 }
Ejemplo n.º 13
0
    /**
     * Initializes the player.
     */
    public void Start()
    {
        CharacterSettings.LoadSettings();

        //initialize location script
        ls = c.GetComponent <Location_Script>();

        //initialize AIFighter brain
        fighterBrain = getFighterBrain();

        //initialize hit points
        this.hitPoints = MAX_HIT_POINTS;

        //initialize mana points
        this.manaPoints = MAX_MANA_POINTS;

        //initialize jumping flag
        this.jumping = false;

        //initialize reset cleared flag
        this.resetCleared = false;

        //initialize set projectile flag
        this.setProjectile = false;

        //initialize the animator
        anim = GetComponent <Animator>();
        anim.SetInteger("Dir", 1);

        //initialize the health points
        healthPoints         = GameObject.FindObjectOfType <Canvas>();
        healthPoints.enabled = true;

        //initialize the color
        this.hitColor    = Color.blue;
        this.normalColor = CharacterSettings.GetColor();
        this.changeToNormalColor();

        //allow the player to move
        canMove    = true;
        speed      = 15;
        setCanMove = false;
        isBlocking = false;
        //set mana cost for certain moves
        manaMelee = 0;
        manaBlock = 5;
        manaRange = 10;
        //set up health cost
        setMeleeAttack  = 5;
        setRangedAttack = 5;
        projSpeed       = 20;
        //gets timer script from camera
        timer = c.GetComponent <Timer>();
    }   //end of Start method
        /// <summary>
        /// Initializes a new instance of the <see cref="GeneticProgramming"/> class.
        /// </summary>
        /// <param name="gw">The gw.</param>
        /// <param name="AI">The ai.</param>
        /// <param name="NAI">The nai.</param>
        /// <param name="torniment_Size">Size of the torniment_.</param>
        /// <param name="pop_size">The pop_size.</param>
        public GeneticProgramming(GameWorld gw, AIFighter AI, NonAIFighter NAI, int torniment_Size, int pop_size)
        {
            generation  = new List <Indevidual>();
            mating_pool = new List <Indevidual>();

            this.gw  = gw;
            this.AI  = AI;
            this.NAI = NAI;

            Torniment_size  = torniment_Size;
            Population_size = pop_size;
        }
Ejemplo n.º 15
0
        public Brain GetBrain(int identifier, AIFighter fighter)
        {
            if (m_initBrains.ContainsKey(identifier))
            {
                return(new InitBrain(fighter, m_initBrains[identifier]));
            }

            if (!m_brains.ContainsKey(identifier))
            {
                return(GetDefaultBrain(fighter));
            }

            return((Brain)Activator.CreateInstance(m_brains[identifier], fighter));
        }
Ejemplo n.º 16
0
 public SpellSelector(AIFighter fighter, EnvironmentAnalyser environment)
 {
     m_environment = environment;
     Fighter       = fighter;
     Possibilities = new List <SpellCastImpact>();
     Priorities    = new Dictionary <SpellCategory, int>
     {
         { SpellCategory.Summoning, 5 },
         { SpellCategory.Buff, 4 },
         { SpellCategory.Damages, 3 },
         { SpellCategory.Healing, 2 },
         { SpellCategory.Curse, 1 }
     };
 }
Ejemplo n.º 17
0
	public void RequestOrders(AIFighter askerScript)
	{
		if(knownEnemyFighters.Count >0)
		{
			askerScript.ChangeToNewState(askerScript.combatStates, new float[]{1});
		}
		else if(knownEnemyTurrets.Count > 0)
		{
			askerScript.ChangeToNewState(askerScript.combatStates, new float[]{1});
		}
		else
		{
			askerScript.ChangeToNewState(askerScript.normalStates, new float[]{1});
		}
	}
Ejemplo n.º 18
0
	void Awake()
	{
		AwakeBaseClass ();

		myAIScript = GetComponent<AIFighter> ();

		rollSkill = normalRollSkill;

		dodgeScript = GetComponentInChildren<Dodge>();

		startSprite = GetComponent<SpriteRenderer> ().sprite;

		if(this.tag == "PlayerFighter")
			thisIsPlayer = true;
	}
Ejemplo n.º 19
0
        public override void SetUp()
        {
            Params.Load("default.properties");
            List <Entity> children = XNAGame.Instance.Children;
            Ground        ground   = new Ground();

            children.Add(ground);
            XNAGame.Instance.Ground = ground;
            AIFighter aiFighter = new AIFighter();

            aiFighter.Position  = new Vector3(-20, 50, 50);
            aiFighter.ModelName = "cobramk1";
            aiFighter.maxSpeed  = 16.0f;
            aiFighter.SwicthState(new IdleState(aiFighter));
            aiFighter.Path.DrawPath = true;
            children.Add(aiFighter);

            Fighter fighter = new Fighter();

            fighter.ModelName = "viper";
            fighter.SteeringBehaviours.turnOn(SteeringBehaviours.behaviour_type.arrive);
            fighter.SteeringBehaviours.turnOn(SteeringBehaviours.behaviour_type.obstacle_avoidance);
            fighter.SteeringBehaviours.turnOn(SteeringBehaviours.behaviour_type.wall_avoidance);
            fighter.Position  = new Vector3(10, 50, 0);
            fighter.TargetPos = aiFighter.Position + new Vector3(-50, 0, -80);
            children.Add(fighter);

            Fighter camFighter = new Fighter();

            camFighter.Leader   = fighter;
            camFighter.offset   = new Vector3(0, 5, 10);
            camFighter.Position = fighter.Position + camFighter.offset;
            camFighter.SteeringBehaviours.turnOn(SteeringBehaviours.behaviour_type.offset_pursuit);
            camFighter.SteeringBehaviours.turnOn(SteeringBehaviours.behaviour_type.wall_avoidance);
            camFighter.SteeringBehaviours.turnOn(SteeringBehaviours.behaviour_type.obstacle_avoidance);
            XNAGame.Instance.CamFighter = camFighter;
            children.Add(camFighter);

            XNAGame.Instance.Leader = fighter;
            Camera camera = XNAGame.Instance.Camera;

            camera.Position = new Vector3(0.0f, 60.0f, 100.0f);

            foreach (Entity child in children)
            {
                child.LoadContent();
            }
        }
Ejemplo n.º 20
0
        /// <summary>
        /// Set up fighters for fight.
        /// </summary>
        /// <param name="isBlocking">if set to <c>true</c> [is blocking].</param>
        /// <param name="isCrouched">if set to <c>true</c> [is crouched].</param>
        /// <param name="torn_size"></param>
        /// <param name="pop_size"></param>
        public void SetUp(bool isBlocking, bool isCrouched, int torn_size, int pop_size) 
        {
            //reset the counters
            treeCounter = 0;
            fighterCounter = 0;
            roundNum = 0;

            ListEventsAlgorithm.Clear();
            ListOfEvents.Clear();

            listOfEvents.Add(":: SET-UP FIGHTERS ::");

            roundNum++;

            listOfEvents.Add("Round NO: " + roundNum);

            //CREATE new NON_AI_FIGHTER
            NoAiFighter = new NonAIFighter(roundNum, isBlocking, isCrouched);

            //set relevent values for NON_AI_FIGHTER
            //NoAiFighter.Blocking = isBlocking;
            //NoAiFighter.Crouching = isCrouched;
            //add new fighter o event list
            listOfEvents.Add(NoAiFighter.ToString());

            //CREATE new AI_FIGHTER
            AiFighter = new AIFighter(roundNum);

             //create a new connection to Genetic programming class
            gp = new GeneticProgramming(this, AiFighter, NoAiFighter,torn_size,pop_size);

            gp.Crouched = Crouched;
            gp.Close = Close;
            gp.Medium = Medium;
            gp.Far = Far;

            //set up the Genetic programming class
            gp.setup();

            //set tree to first in generation list
            treeCounter = 0;
            AiFighter.Tree = gp.Generation[treeCounter];

            //add AI fighter to list
            listOfEvents.Add(AiFighter.ToString());
        }
Ejemplo n.º 21
0
        public Brain GetBrain(int identifier, AIFighter fighter)
        {
            Brain result;

            if (!this.m_brains.ContainsKey(identifier))
            {
                result = this.GetDefaultBrain(fighter);
            }
            else
            {
                System.Type type = this.m_brains[identifier];
                result = (Brain)System.Activator.CreateInstance(type, new object[]
                {
                    fighter
                });
            }
            return(result);
        }
        public override void SetUp()
        {
            Params.Load("default.properties");
            List<Entity> children = XNAGame.Instance.Children;
            Ground ground = new Ground();
            children.Add(ground);
            XNAGame.Instance.Ground = ground;
            AIFighter aiFighter = new AIFighter();
            aiFighter.Position = new Vector3(-20, 50, 50);
            aiFighter.ModelName = "cobramk1";
            aiFighter.maxSpeed = 16.0f;
            aiFighter.SwicthState(new IdleState(aiFighter));
            aiFighter.Path.DrawPath = true;
            children.Add(aiFighter);

            Fighter fighter = new Fighter();
            fighter.ModelName = "viper";
            fighter.SteeringBehaviours.turnOn(SteeringBehaviours.behaviour_type.arrive);
            fighter.SteeringBehaviours.turnOn(SteeringBehaviours.behaviour_type.obstacle_avoidance);
            fighter.SteeringBehaviours.turnOn(SteeringBehaviours.behaviour_type.wall_avoidance);
            fighter.Position = new Vector3(10, 50, 0);
            fighter.TargetPos = aiFighter.Position + new Vector3(-50, 0, -80);
            children.Add(fighter);

            Fighter camFighter = new Fighter();
            camFighter.Leader = fighter;
            camFighter.offset = new Vector3(0, 5, 10);
            camFighter.Position = fighter.Position + camFighter.offset;
            camFighter.SteeringBehaviours.turnOn(SteeringBehaviours.behaviour_type.offset_pursuit);
            camFighter.SteeringBehaviours.turnOn(SteeringBehaviours.behaviour_type.wall_avoidance);
            camFighter.SteeringBehaviours.turnOn(SteeringBehaviours.behaviour_type.obstacle_avoidance);
            XNAGame.Instance.CamFighter = camFighter;
            children.Add(camFighter);

            XNAGame.Instance.Leader = fighter;
            Camera camera = XNAGame.Instance.Camera;
            camera.Position = new Vector3(0.0f, 60.0f, 100.0f);

            foreach (Entity child in children)
            {
                child.LoadContent();
            }
        }
        public void Handling_Fight_Event_Distance_Far_Attack_Type_Special()
        {
            //arrange
            AIFighter    attacker = new AIFighter(1);
            NonAIFighter defender = new NonAIFighter(1, false, false);

            IGameWorld gw = new GameWorld();

            //set up
            gw.Distance     = "Far";
            attacker.Attack = new Special();

            String expected = "Far Damage: AI-Fighter <<Special Move>> Non-AI-Fighter <<For>> <-30>";

            //act
            string actual = gw.wAttack(attacker, defender, attacker.Attack);

            //assert
            Assert.AreEqual(expected, actual, "The correct attack result was returned");
        }
        public void Handling_Fight_Event_Distance_Close_Attack_Type_Punch_Blocking()
        {
            //arrange
            AIFighter    attacker = new AIFighter(1);
            NonAIFighter defender = new NonAIFighter(1, true, false);

            //Attack attack = attacker.GenAttack();

            IGameWorld gw = new GameWorld();

            //set up
            gw.Distance     = "Close";
            attacker.Attack = new Punch();

            String expected = "Close Damage: AI-Fighter <<Punch>> Non-AI-Fighter <<For>> <-5>";

            //act
            string actual = gw.wAttack(attacker, defender, attacker.Attack);

            //assert

            Assert.AreEqual(expected, actual, " the incorrect attack result was returned");
        }
Ejemplo n.º 25
0
 public MoveFarFrom(AIFighter fighter, FightActor from)
     : base(fighter)
 {
     From = from;
 }
Ejemplo n.º 26
0
 public MoveAction(AIFighter fighter, Cell destinationCell)
     : base(fighter)
 {
     DestinationCell = destinationCell;
 }
Ejemplo n.º 27
0
 public AttackAction(AIFighter fighter)
     : base(fighter)
 {
     AttackState = AttackStateEnum.STATE_CALCULATE_CELLS;
 }
Ejemplo n.º 28
0
 public MoveAction(AIFighter fighter)
     : base(fighter)
 {
 }
Ejemplo n.º 29
0
 public DefaultAIBrain(AIFighter fighter)
     : base(fighter)
 {
 }
 public EnvironmentAnalyser(AIFighter fighter)
 {
     this.Fighter = fighter;
     this.CellInformationProvider = new AIFightCellsInformationProvider(this.Fighter.Fight, this.Fighter);
 }
Ejemplo n.º 31
0
 public FleeAction(AIFighter fighter)
     : base(fighter)
 {
 }
Ejemplo n.º 32
0
 protected AIBrain(AIFighter fighter)
 {
     Fighter = fighter;
 }
Ejemplo n.º 33
0
 public AIFightCellsInformationProvider(Fight fight, AIFighter fighter) : base(fight)
 {
     this.Fighter = fighter;
 }
Ejemplo n.º 34
0
 public SpellCastAction(AIFighter fighter, Spell spell, Cell target) : base(fighter)
 {
     this.Spell  = spell;
     this.Target = target;
 }
Ejemplo n.º 35
0
 public SynchroBrain(AIFighter fighter)
     : base(fighter)
 {
     fighter.Team.FighterAdded += OnFighterAdded;
 }
Ejemplo n.º 36
0
        private void OnTick(object sender, EventArgs e)
        {
            try
            {
                if (scriptActive)
                {
                    Game.Player.WantedLevel = 0;
                    Function.Call(Hash.SET_VEHICLE_DENSITY_MULTIPLIER_THIS_FRAME, 0.1f);

                    TeamManager.Update();
                    LocalPlayer.Update();

                    #region Update Fighters

                    var activeFighters = TeamManager.GetActiveFighters().ToList();

                    if (World.GetAllVehicles().Length < 100)
                    {
                        if (activeFighters.Count < Config.MaxPlayers)
                        {
                            AIFighter aiPlayer = new AIFighter();
                            TeamManager.SetupTeam(aiPlayer);
                            aiPlayer.Setup();
                        }
                    }

                    for (int i = 0; i < activeFighters.Count; i++)
                    {
                        var fighter = activeFighters[i];

                        if (fighter is LocalFighter) continue;

                        fighter.Update();

                        if (fighter.ManagedPed.IsDead || fighter.ManagedPed.IsInWater)
                        {
                            var GET_PED_KILLER = 0x93C8B64DEB84728C;
                            var mKiller = Function.Call<Entity>((Hash)GET_PED_KILLER, fighter.ManagedPed.Handle);

                            if (mKiller != null)
                            {
                                if (mKiller.Handle == LocalPlayer.ManagedPed.Handle ||
                                    mKiller.Handle == LocalPlayer.ManagedVehicle.Handle)
                                {
                                    if (fighter.Team.Index == LocalPlayer.Team.Index)
                                    {
                                        UIManager.DisplayKillInfoUI(fighter, 6000);
                                        UI.Notify("~r~Team Kill Penalty!");
                                        TeamManager.RegisterScoreForTeam(LocalPlayer.Team, -250); ;
                                    }

                                    else
                                    {
                                        UIManager.DisplayKillInfoUI(fighter, 6000);
                                        TeamManager.RegisterScoreForTeam(LocalPlayer.Team, 250);
                                        ExpRankManager.AddRankPoints(100, true);
                                    }
                                }

                                else
                                {
                                    foreach (var eFighter in activeFighters)
                                    {
                                        if (eFighter.Team.Index == fighter.Team.Index) continue;
                                        if (eFighter.ManagedPed.Handle == mKiller.Handle || eFighter.ManagedVehicle.Handle == mKiller.Handle)
                                        {
                                            TeamManager.RegisterScoreForTeam(eFighter.Team, 350);
                                        }
                                    }
                                }
                            }

                            else
                            {
                                var killer = activeFighters.Find(x => fighter.ManagedVehicle.HasBeenDamagedBy(x.ManagedPed));

                                if (killer != null)
                                {
                                    if (fighter.Team.Index == killer.Team.Index)
                                    {
                                        if (killer == LocalPlayer)
                                        {
                                            UIManager.DisplayKillInfoUI(fighter, 6000);
                                            UI.Notify("~r~Team Damage Penalty!");
                                            TeamManager.RegisterScoreForTeam(killer.Team, -250);
                                        }
                                    }

                                    else
                                    {
                                        if (killer == LocalPlayer)
                                        {
                                            UIManager.DisplayKillInfoUI(fighter, 6000);
                                            TeamManager.RegisterScoreForTeam(killer.Team, 250);
                                            ExpRankManager.AddRankPoints(100, true);
                                        }

                                        else
                                            TeamManager.RegisterScoreForTeam(killer.Team, 250);
                                    }
                                }
                            }

                            //stop updating this fighter.
                            TeamManager.StopUpdate(fighter);
                            fighter.MarkAsNoLongerNeeded();
                        }

                        else if (fighter.ManagedPed.IsInWater)
                        {
                            //stop updating this fighter.
                            TeamManager.StopUpdate(fighter);
                            fighter.MarkAsNoLongerNeeded();
                        }
                    }
                    #endregion
                }
            }

            catch
            {
                //notify user of the error.
                UI.Notify("~r~Air Superiority experienced a crash.");
                //continue throwing the exception.
                throw;
            }
        }
Ejemplo n.º 37
0
 public MoveAction(AIFighter fighter, MapPoint destination)
     : base(fighter)
 {
     Destination = destination;
 }
Ejemplo n.º 38
0
 public ThreatCalculator(AIFighter fighter)
 {
     Fighter = fighter;
 }
Ejemplo n.º 39
0
 public EndTurnAction(AIFighter fighter)
     : base(fighter)
 {
 }