コード例 #1
0
ファイル: AttackAgent.cs プロジェクト: srferran/ES2015A
		/// <summary>
		/// Gets the confidence of this squad.
		/// </summary>
		/// <returns>The confidence.</returns>
		/// <param name="squad">Squad.</param>
        public override int getConfidence(Squad squad)
        {
            if (squad.EnemySquad.Units.Count == 0)
                return 0;

            //Get the ratio of how better we are comparing us with the enemy army
            supremaciIndex = squad.Attack / squad.EnemySquad.Attack;

            //If is an infinity number we return 0
            supremaciIndex = supremaciIndex == Mathf.Infinity ? 0 : supremaciIndex;

            //Return the formula explained on the Issue max(n, 5) * 75
            if (supremaciIndex > 0f)
            {
                conf = Mathf.RoundToInt(Mathf.Min(supremaciIndex, CONFIDENCE_OWN_SQUAD_SUPREMACI_MAX_MULTITPLIER) * CONFIDENCE_OWN_SQUAD_SUPREMACY);

                //We need to check if the enemy squad has hero inside
                foreach (Unit u in squad.EnemySquad.Units)
                {
                    if(u.type == Storage.UnitTypes.HERO)
                    {
                        conf += CONFIDENCE_ENEMY_SQUAD_HAS_HERO;
                        break;
                    }
                }

                return conf;
            }

            return 0;

        }
コード例 #2
0
ファイル: Adventure.cs プロジェクト: jiowchern/Regulus
 public Adventure(Adventurer adventurer, Remoting.ISoulBinder binder, IZone zone)
 {
     _Adventurer = adventurer;
     _Zone = zone;
     this._Binder = binder;
     _Squad = new Squad(adventurer.Formation ,_Adventurer.Teammates, _Adventurer.Controller);
 }
コード例 #3
0
 public EnemySquad(Squad squad, Vector3 destination)
 {
     mWaypoints = new List<Vector3> ();
     mWaypoints.Add(destination);
     mSquad = squad;
     mSquad.SetDestination(mWaypoints[0]);
 }
コード例 #4
0
        public void Tick(Squad owner)
        {
            if (!owner.IsValid)
                return;

            if (!owner.IsTargetValid)
            {
                owner.TargetActor = owner.Bot.FindClosestEnemy(owner.CenterPosition, WDist.FromCells(8));

                if (owner.TargetActor == null)
                {
                    owner.FuzzyStateMachine.ChangeState(owner, new UnitsForProtectionFleeState(), true);
                    return;
                }
            }

            if (!owner.IsTargetVisible)
            {
                if (Backoff < 0)
                {
                    owner.FuzzyStateMachine.ChangeState(owner, new UnitsForProtectionFleeState(), true);
                    Backoff = BackoffTicks;
                    return;
                }

                Backoff--;
            }
            else
            {
                foreach (var a in owner.Units)
                    owner.Bot.QueueOrder(new Order("AttackMove", a, false) { TargetLocation = owner.TargetActor.Location });
            }
        }
コード例 #5
0
    public void CreateBattleGroup(Squad _squad, GameObject battleGroup)
    {
        battleGroup.name = _squad.isPlayer ? "playerSquad" : "enemySquad";
        battleGroup.transform.position = Vector3.zero;

        for(int i = 0; i < _squad.members.Count; i++)
        {
            //parent the squad members to battlegroup
            _squad.members[i].piece.transform.parent = battleGroup.transform;

            //calculate position
            sizeOffset = ((int)_squad.members[i].sheet.size - 1) * Vector3.one * 0.5f * scaleDistBetweenUnits;
            spawnLocation = new Vector3(_squad.members[i].sheet.squadLocX, _squad.members[i].sheet.squadLocY, _squad.members[i].sheet.squadLocY) * scaleDistBetweenUnits;
            _squad.members[i].piece.transform.localPosition = spawnLocation + playerSquadOffset + sizeOffset;
            _squad.members[i].piece.gameObject.SetActive(true);
            _squad.members[i].piece.Initialize(_squad.members[i].sheet,i);

            //add reference of all units ot battle manager
            unitsInBattle.Add(_squad.members[i]);
        }

        // invert enemy squad facing
        if(!_squad.isPlayer)
            battleGroup.transform.localScale = new Vector3(battleGroup.transform.localScale.x * -1, battleGroup.transform.localScale.y, battleGroup.transform.localScale.z);
    }
コード例 #6
0
ファイル: GnomeSquad.cs プロジェクト: Rychard/GnomeServer
        public GnomeSquad(Squad squad)
        {
            var skillDefinitions = GnomanEmpire.Instance.GetSkillDefs();
            var gnomesInSquad = squad.Members.Where(obj => obj != null).Select(obj => new Gnome(obj, skillDefinitions)).ToArray();

            Name = squad.Name;
            Gnomes = gnomesInSquad;
        }
コード例 #7
0
        public void Tick(Squad owner)
        {
            if (!owner.IsValid)
                return;

            GoToRandomOwnBuilding(owner);
            owner.FuzzyStateMachine.ChangeState(owner, new UnitsForProtectionIdleState(), true);
        }
コード例 #8
0
ファイル: DroneEnemy.cs プロジェクト: ReinAkane/Monotopia
	void AddFollower(Enemy follower, Squad s)
	{
		DroneEnemy de = follower as DroneEnemy;
		if (de == null) return;
		
		de.Follow(this);
		
		s.NewSquadMember -= AddFollower;
	}
コード例 #9
0
ファイル: BattleManager.cs プロジェクト: EunoiaGames/MTW
    public void SelectSquad(Squad targetSquad)
    {
        Debug.Log("Selected a Squad");
        if (selectedSquad != targetSquad || selectedSquad == null)
        {
            if(selectedSquad != null)
                selectedSquad.OnDeselected();

            selectedSquad = targetSquad;
            selectedSquad.OnSelected();
        }
        //CameraManager.get.SnapToTarget(selectedSquad.transform);
    }
コード例 #10
0
ファイル: StateMachine.cs プロジェクト: RobotCaleb/OpenRA
        public void ChangeState(Squad squad, IState newState, bool rememberPrevious)
        {
            if (rememberPrevious)
                previousState = currentState;

            if (currentState != null)
                currentState.Deactivate(squad);

            if (newState != null)
                currentState = newState;

            currentState.Activate(squad);
        }
コード例 #11
0
ファイル: CombinerSquad.cs プロジェクト: ReinAkane/Monotopia
	public virtual void Scatter(Enemy en = null, Squad s = null)
	{
		foreach (CombinerEnemy e in this)
		{
			e.Destination = new Vector3(Random.Range(-125f, 125f), 0f, Random.Range(-75f, -150f));
			e.destination.rotation = e.no_rotation;
			e.ute = false;
			
			e.DestinationReached += Gather;
			e.DestinationReached -= e.CommenceFiring;
			e.charges = 0;
		}
	}
コード例 #12
0
        public IResponseFormatter Assign()
        {
            var game = GnomanEmpire.Instance;
            var playerFaction = game.World.AIDirector.PlayerFaction;
            var gnomes = game.GetGnomes();
            foreach (var gnome in gnomes)
            {
                // Because we are potentially creating squads inside this loop, we should always refresh this collection on each iteration.
                var squads = game.Fortress.Military.Squads;

                // Check to see if the gnome is already in a squad.
                // If not, assign them to the first squad with an available slot.
                // TODO: Should we apply a more complex algorithm for this?  Ideally we would optimize the selection to optimize the quality of the military.
                if (gnome.Squad == null)
                {
                    Boolean added = false;
                    foreach (var squad in squads)
                    {
                        // A Squad can only have 5 Gnomes in it.
                        for (UInt32 i = 0; i < 5; i++)
                        {
                            Boolean isVacant = (squad.Members[i] == null);
                            if (isVacant)
                            {
                                added = true;
                                squad.AddMember(i, gnome);
                            }
                        }
                    }

                    // Determine if the Gnome remains unassigned to a squad.
                    if (!added)
                    {
                        // This must indicate that all existing squads are full, so we need a new Squad.

                        // The game generates a random name for all new Squads.  We'll do the same.
                        var squadName = game.GameDefs.LanguageSettings.RandomSquadName(playerFaction.FactionDef.LanguageID);
                        Squad emptySquad = new Squad(squadName);

                        // TODO: Set a formation?
                        game.Fortress.Military.AddSquad(emptySquad);

                        // Lastly, add our Gnome to the newly created Squad.
                        emptySquad.AddMember(0, gnome);
                    }
                }
            }

            // After assigning our Gnomes to the Squads, we'll redirect to the standard endpoint.
            return Get();
        }
コード例 #13
0
ファイル: AssistAgent.cs プロジェクト: srferran/ES2015A
 public void requestHelp(Squad s, int priority)
 {
     int extra = 0;
     //Give extra priority to requests with the hero
     foreach (Unit u in s.Units)
     {
         if (u.type == Storage.UnitTypes.HERO)
         {
             extra = 20;
         }
     }
     requestData r = new requestData(priority+extra);
     requests.Add(new KeyValuePair<Squad, requestData>(s,r));
 }
コード例 #14
0
ファイル: Military.cs プロジェクト: Rfvgyhn/gnomoriamods
        public void RemoveSquad(Squad squad)
        {
            var index = GetSquadIndex(squad);
            attackTargets.Remove(index);

            var needToMove = attackTargets.Where(d => d.Key > index).ToArray();

            for (var i = 0; i < needToMove.Length; i++)
            {
                var kvp = needToMove[i];
                attackTargets.Add(kvp.Key - 1, kvp.Value);
                attackTargets.Remove(kvp.Key);
            }
        }
コード例 #15
0
ファイル: UserInput.cs プロジェクト: derogers/RTS_Game
    // If left mouse click
    private void LeftMouseClick()
    {
        //If the Mouse is in bounds, actually do something
        if (player.hud.MouseInBounds ())
        {
            // Save whatever you clicked on to hitObject using the FindHitObject function
            GameObject hitObject = FindHitObject ();

            // Find where the mouse click was using FindHitPoint function
            hitPoint = FindHitPoint ();

            //If you hit an object in a valid position
            if(hitObject && hitPoint != ResourceManager.InvalidPosition)
            {
                //If you already have something selected
                if(player.SelectedObject)
                {
                    //If the player has a unit selected
                    if(player.SelectedObject.tag == "Unit")
                    {
                        holdSquad = ResourceManager.GetUnit (player.SelectedObject.name).squad;
                        player.SelectedObject.MouseClickSquad(holdSquad, hitPoint, player);
                    }
                    //If the player doesnt have a unit selected, proceed as normal
                    //Each class can write an override function for MouseClick
                    else
                    {
                        player.SelectedObject.MouseClick(hitObject, hitPoint, player);
                    }
                }
                //If you dont have anything selected and you didnt click on the ground
                else if(hitObject.tag != "Ground")
                {
                    Debug.Log (hitObject);
                    //Set worldObject to whatever you clicked on
                    WorldObject worldObject = hitObject.transform.parent.GetComponent<WorldObject>();
                    //If you actually clicked on something
                    if(worldObject)
                    {
                        //we already know the player has no selected object
                        //So we set whatever they clicked on to thier selected object
                        player.SelectedObject = worldObject;
                        //Set it so the game knows they have something selected
                        worldObject.SetSelection(true, player.hud.GetPlayingArea());
                    }
                }
            }
        }
    }
コード例 #16
0
ファイル: Unit.cs プロジェクト: EunoiaGames/MTW
 public void DeployUnit(UnitSpawnPos targetPos, Squad targetSquad)
 {
     attachedSquad = targetSquad;
     _spawningParticles = PoolMaster.SpawnRandomReference("PS_Deploying", this.transform.position).GetComponent<ParticleSystem>();
     _spawningParticles.transform.SetParent(this.transform);
     _spawningParticles.Play();
     spawnPos = targetPos;
     this.transform.position = spawnPos.GetPos() + Vector3.up * 100;
     iTween.MoveTo(this.gameObject, iTween.Hash(
         "position", targetPos.GetPos(),
         "time", Random.Range(1f,2f),
         "isLocal",true ,
         "easetype", iTween.EaseType.linear,
         "oncomplete", "DeploymentComplete"));
 }
コード例 #17
0
ファイル: WorldObject.cs プロジェクト: derogers/RTS_Game
    public virtual void MouseClickSquad(Squad holdSquad, Vector3 hitPoint, Player player)
    {
        //only handle input if currently selected
        if(currentlySelected && holdSquad && holdSquad.tag != "Ground")
        {
            //This is the part that is messed up, is a recursive function that should do something else.....
            Squad squad = holdSquad;//holdSquad.transform.parent.GetComponent< Squad >(); // currently this value is null when click on the ground
            squad.MouseClickSquad(holdSquad, hitPoint, player);

            // this makes is so if you click, it deselects the squad
            if(squad)
            {
                //ChangeSelection(squad, player);
            }
        }
    }
コード例 #18
0
ファイル: UnitList.cs プロジェクト: kumikumi/desertwar
 private void selectSquad(Squad squad)
 {
     if (selectedSquad == squad) {
         return;
     }
     if (selectedSquad != null) {
         selectedSquad.gameObject.GetComponent<Image> ().enabled = false;
         foreach (Unit unit in selectedSquad.units) {
             unit.selection.enabled = false;
         }
     }
     selectedSquad = squad;
     selectedSquad.gameObject.GetComponent<Image> ().enabled = true;
     foreach (Unit unit in selectedSquad.units) {
         unit.selection.enabled = true;
     }
 }
コード例 #19
0
ファイル: StrategyAgent.cs プロジェクト: srferran/ES2015A
 public override void controlUnits(Squad squad)
 {
     if (attacking)
     {
         if(target != null && target.status != EntityStatus.DESTROYED)
         {
             squad.AttackTo(target);
         }
         else
         {
             findTarget();
         }
     }
     else
     {
         //Add patrolling
         if (patrolPoints.Count > 0)
         {
             int posInd = squad.PatrolPosition;
             Vector3 targetPos = patrolPoints[posInd];
             Vector2 sc = squad.BoundingBox.Bounds.center;
             if (Vector3.Distance(new Vector3(sc.x, targetPos.y, sc.y), targetPos) < 5)
             {
                 //Got to the destination, let's go for the next one
                 if (posInd >= patrolPoints.Count - 1)
                 {
                     posInd = 0;
                 }
                 else
                 {
                     posInd++;
                 }
                 targetPos = patrolPoints[posInd];
                 squad.PatrolPosition = posInd;
             }
             squad.MoveTo(targetPos);
         }
     }
     if (AIController.AI_DEBUG_ENABLED)
     {
         foreach (Unit u in squad.Units)
         {
             ai.aiDebug.registerDebugInfoAboutUnit(u, agentName);
         }                
     }
 }
コード例 #20
0
ファイル: RetreatAgent.cs プロジェクト: srferran/ES2015A
        public override void controlUnits(Squad squad)
        {
            // Mirar on estan els enemics
            enemySquadBoundingBox = squad.EnemySquad.BoundingBox.Bounds;

            // Mirar on estic jo
            ownSquadBoundingBox = squad.BoundingBox.Bounds;

            // Intentar Veure on hauria d'anar una unitat per estar protegida
            recalcSafePoint();
            if (squad.UserData == this && squad.NotMoved)//If this was the last agent to take control and we haven't moved we probably did something wrong
            {
                Vector3 resPoint= Vector3.zero;
                Vector3 squadCenter = new Vector3(ownSquadBoundingBox.center.x, safeArea.y, ownSquadBoundingBox.y);
                Vector3 newPoint = Quaternion.Euler(0, 90, 0) * (safeArea - squadCenter) + squadCenter;
                if (DetourCrowd.Instance.RandomValidPointInCircle(newPoint, 20,ref resPoint))
                {
                    safeArea = resPoint;
                }
                else
                {
                    //OH NO! CONCAVE GEOGRAPHY, MY ONLY WEAKNESS.
                    //There is no safe point ahead, so let's just pray to the dice gods.
                    if (DetourCrowd.Instance.RandomValidPointInCircle(squadCenter, 20, ref resPoint))
                    {
                        safeArea = resPoint;
                    }
                }
            }
            foreach (Unit u in squad.Units)
            {
                if (u.status != EntityStatus.DEAD)
                {
                    u.moveTo(safeArea);
                }

                if (AIController.AI_DEBUG_ENABLED)
                {
                    ai.aiDebug.registerDebugInfoAboutUnit(u, this.agentName);
                }
            }
            assistAgent.requestHelp(squad, CONFIDENCE_ASSIST_HELP_NEEDED);
        }
コード例 #21
0
		public void Tick(Squad owner)
		{
			if (!owner.IsValid)
				return;

			if (!owner.TargetIsValid)
			{
				owner.Target = owner.bot.FindClosestEnemy(owner.CenterPosition, WRange.FromCells(8));

				if (owner.Target == null)
				{
					owner.fsm.ChangeState(owner, new UnitsForProtectionFleeState(), true);
					return;
				}
			}

			foreach (var a in owner.units)
				owner.world.IssueOrder(new Order("AttackMove", a, false) { TargetLocation = owner.Target.Location });
		}
コード例 #22
0
ファイル: UIManager.cs プロジェクト: Cestt/Swarmpositorio
	// Use this for initialization
	void Awake () {
		buttonNewSpawn = transform.FindChild ("ButtonNewSpawn").GetComponent<Button> ();
		buttonCreateCreep1 = transform.FindChild ("ButtonCreateCreep1").GetComponent<Button> ();
		buttonSkillSquad = transform.FindChild ("ButtonSkillSquad").GetComponent<Button> ();
		buttonEvolveSquad1 = transform.FindChild ("ButtonEvolveSquad1").GetComponent<Button> ();
		buttonEvolveSquad2 = transform.FindChild ("ButtonEvolveSquad2").GetComponent<Button> ();
		selectedTxt = transform.FindChild ("SelectedText").GetComponent<Text> ();
		/*buttonEvolveSpawnT1 = transform.FindChild ("ButtonEvolveSpawnT1").GetComponent<Button> ();
		buttonEvolveSpawnT2 = transform.FindChild ("ButtonEvolveSpawnT2").GetComponent<Button> ();
		buttonEvolveCreepA = transform.FindChild ("ButtonEvolveCreepA").GetComponent<Button> ();
		buttonEvolveCreepB = transform.FindChild ("ButtonEvolveCreepB").GetComponent<Button> ();
		buttonSkillSpawn = transform.FindChild ("ButtonSkillSpawn").GetComponent<Button> ();
		buttonAddBioPool = transform.FindChild ("ButtonAddBioPool").GetComponent<Button> ();
		buttonEvolveCreepA.interactable = false;
		buttonEvolveCreepB.interactable = false;
		buttonEvolveSpawnT2.interactable = false;
		buttonSkillSpawn.interactable = false;*/
		touchManager = GameObject.Find ("GameManager/TouchManager").GetComponent<TouchManager> ();
		pool = GameObject.Find ("Pool").GetComponent<Pool> ();
		badgerSq = pool.prefabSquadBadger.GetComponentInChildren<Squad> ();
	}
コード例 #23
0
ファイル: Projectile.cs プロジェクト: EunoiaGames/MTW
    public void Init(string[] weaponFireInfo, int weaponRange, int weaponDmg ,Vector3 targetPoint, Squad targetSquad, bool willHit)
    {
        _wpnFireInfo = weaponFireInfo;
        _targetPos = targetPoint;
        _targetSquad = targetSquad;
        _weaponDmg = weaponDmg;
        _willHitTarget = willHit;
        _isActive = true;

        ToggleProjectileViz(weaponFireInfo[2], true);
        SetProjectileSpeed();

        switch (weaponFireInfo[0])
        {
            case "arc":
                ///Extremely simple arcing artillery shot distance essentially just move the projectile itself along normal path then use Itween
                /// to add a vertical arc on the visuals;
                float dist = (weaponRange *1.25f) - Vector3.Distance(this.transform.position, _targetPos);
                dist = Mathf.Clamp(dist, 10, 35);

                iTween.MoveBy(projectileVis, iTween.Hash("y", dist, "time", _spd / 2 , "easeType", iTween.EaseType.easeOutQuad));
                iTween.MoveBy(projectileVis, iTween.Hash("y", -dist, "time", _spd / 2, "delay", _spd / 2, "easeType", iTween.EaseType.easeInCubic));

                iTween.MoveTo(this.gameObject, iTween.Hash(
                    "easetype", iTween.EaseType.linear,
                    "position", (_targetPos + Vector3.up) + Random.insideUnitSphere*2,
                    "time", _spd,
                    "oncomplete", "DestroyThis"));
                break;

            ///Default fire mode is simple direct fire
            default:
                iTween.MoveTo(this.gameObject, iTween.Hash(
                    "easetype", iTween.EaseType.linear,
                    "position", (_targetPos + Vector3.up) + Random.insideUnitSphere * 2,
                    "speed", _spd*4,
                    "oncomplete", "DestroyThis"));
                break;
        }
    }
コード例 #24
0
ファイル: AssistAgent.cs プロジェクト: srferran/ES2015A
		public override int getConfidence(Squad squad)
		{
            if(requests.Count == 0)
            {
                return 0;
            }
            int bConfidence = int.MinValue;
            Squad bSquad = null;
            //Go to help the closest and more important request
            foreach(KeyValuePair<Squad, requestData> request in requests)
            {
                //I know they say you should help yourself before asking others, but I don't think this is what they mean.
                if(request.Key!= squad)
                {
                    int conf = request.Value.Priority;
                    float dist = Vector2.Distance(request.Key.BoundingBox.Bounds.center, squad.BoundingBox.Bounds.center);
                    if (ai.StoryMode && dist > 20)
                    {
                        conf = 0;
                    }
                    else if (dist > 200)
                    {
                        conf = conf / 4;
                    }
                    else if (dist > 100)
                    {
                        conf = conf / 2;
                    }
                    if (conf > bConfidence)
                    {
                        bConfidence = conf;
                        bSquad = request.Key;
                    }
                }
            }
            squad.AssistSquad = bSquad;
			return Mathf.Max(0,bConfidence);
		}
コード例 #25
0
ファイル: AttackAgent.cs プロジェクト: srferran/ES2015A
        public override void controlUnits(Squad squad)
        {
            if (squad.EnemySquad.Units.Count > 0)
            {
                //Debug.Log(squad.Units[0] + " " + squad.EnemySquad.Units[0]);

                foreach (Unit u in squad.Units)
                {
                    //Select target
                    Unit bTar = null;
                    float bVal = float.MinValue;
                    foreach (Unit e in squad.EnemySquad.Units)
                    {
                        float val = -Vector3.Distance(u.transform.position, e.transform.position);
                        if (u.type == Storage.UnitTypes.HERO)
                            val += 80;
                        if (u.healthPercentage < 20)
                            val += 15;
                        if (val > bVal)
                        {
                            bVal = val;
                            bTar = e;
                        }
                    }
                    IGameEntity target = u.getTarget();
                    if (bTar.status!=EntityStatus.DEAD && u.status != EntityStatus.DEAD &&
                       (target==null || (!target.info.isUnit || (Unit)target != bTar)))
                    {
                        u.attackTarget(bTar);
                    }
                    if (AIController.AI_DEBUG_ENABLED)
                    {
                        ai.aiDebug.registerDebugInfoAboutUnit(u, this.agentName);
                    }
                }
                assistAgent.requestHelp(squad, REQUEST_PRIORITY);
            }
        }
コード例 #26
0
ファイル: Squad.cs プロジェクト: derogers/RTS_Game
    public override void MouseClickSquad(Squad holdSquad, Vector3 hitPoint, Player player)
    {
        // calls the MouseClickSquad function in WorldObject.cs
        base.MouseClickSquad(holdSquad, hitPoint, player);

        //only handle input if owned by a human player and currently selected
        if(player && player.human) // && currently Selected
                                   // ^ took that out because I think its redundant
        {
            //Debug.Log ( holdSquad);
            //this if statement probably wont work because holdSquad.tag != Ground if it is suppose to. Not sure how fix this yet
            if(holdSquad.tag != "Ground" && hitPoint != ResourceManager.InvalidPosition)
            {
                //units = need to call getunit somehow
                float x = hitPoint.x;
                //makes sure that the unit stays on top of the surface it is on
                //might be the cause of a bug where The destination points are too high up
                //might be able to just get rid of player.SelectedObject.transform.position.y and fix it
                //as of now i think its fine...
                float y = hitPoint.y;//player.SelectedObject.transform.position.y;
                float z = hitPoint.z;

                //calculates what direction the squad should face
                squadRotation = SquadFormationManager.calculateSquadRotation(Tforms[0].position, new Vector3(x,y,z));
                //Debug.Log (squadRotation);

                movingUp = SquadFormationManager.squadMovingUp(Tforms[0].position, new Vector3(x,y,z));

                //makes a vector3[] to assign all the units to
                destinations = SquadFormationManager.calculateSquadPositions(seperation,squadRotation, new Vector3(x,y,z), movingUp);

                for(int i = 0; i < units.Length; i++)
                {
                    Tforms[i].position = destinations[i];
                }
            }
        }
    }
コード例 #27
0
    public void StartNewBattle(Squad _playerSquad, Squad _enemySquad)
    {
        playerSquad = _playerSquad;
        enemySquad = _enemySquad;

        ellapsedTime = 0f;

        SoundManager.SM.PlaySfx(battleStart);

        playerBattleGroup = new GameObject();
        enemyBattleGroup = new GameObject();
        CreateBattleGroup(playerSquad, playerBattleGroup);
        CreateBattleGroup(enemySquad, enemyBattleGroup);

        RollInitative();

        //set up action
        for(int i = 0; i < unitsInBattle.Count; i++)
        {
            SetNextAction(unitsInBattle[i]);
        }

        CalculateActOrder();
    }
コード例 #28
0
ファイル: AssistAgent.cs プロジェクト: srferran/ES2015A
		public override void controlUnits(Squad squad)
		{
            Squad assisted = squad.AssistSquad;
            Vector2 cent = assisted.BoundingBox.Bounds.center;
            float y = (assisted.Units.Count>0)? assisted.Units[0].transform.position.y : 80f;
            Vector3 pos = new Vector3(cent.x, y, cent.y);
            Vector2 ocent = squad.BoundingBox.Bounds.center;
            if (Vector2.Distance(cent, ocent) < 20) //join squads
            {
                assisted.AddUnits(squad.Units);
                ai.Micro.squads.Remove(squad);
            }else
            {
                //Go to the most important request squad
                foreach (Unit u in squad.Units)
                {
                    u.moveTo(pos);
                    if (AIController.AI_DEBUG_ENABLED)
                    {
                        ai.aiDebug.registerDebugInfoAboutUnit(u, this.agentName);
                    }
                }
            }
		}
コード例 #29
0
ファイル: RetreatAgent.cs プロジェクト: srferran/ES2015A
        public override int getConfidence(Squad squad)
        {
            //Get the squad bounding box
            ownSquadBoundingBox = squad.BoundingBox.Bounds;
            int confidence = 0;
            foreach (Unit enemyUnit in squad.EnemySquad.Units)
            {
                foreach (Unit ownUnit in squad.Units)
                {
                    float distance = Vector3.Distance(enemyUnit.transform.position, ownUnit.transform.position);
                    if (distance < enemyUnit.currentAttackRange() + 100)
                    {
                        //If our hero is in range and is going to die
                        if(ownUnit.type == Storage.UnitTypes.HERO && ownUnit.healthPercentage < HERO_HEALTH_TOLERANCE_BEFORE_RETREAT)
                        {
                            return CONFIDENCE_HERO_IS_AT_FIFTY_PERCENT;      
                        }

                        confidence = CONFIDENCE_IN_ENEMY_ATACK_RANGE;
                    }
                }
            }
            return confidence;
        }
コード例 #30
0
            private void StartMovement()
            {
                Tuple <int, int> Target      = (Tuple <int, int>)ArrayReferences[0].ReferencedScript.GetContent();
                Squad            TargetSquad = Info.Map.ListPlayer[Target.Item1].ListSquad[Target.Item2];

                Unit    CurrentActiveUnit   = Info.ActiveSquad.CurrentLeader;
                Vector3 ActiveSquadPosition = Info.ActiveSquad.Position;

                //Define the minimum and maximum value of the attack range.
                int MinRange = Info.ActiveSquad.CurrentLeader.CurrentAttack.RangeMinimum;
                int MaxRange = Info.ActiveSquad.CurrentLeader.CurrentAttack.RangeMaximum;

                if (MaxRange > 1)
                {
                    MaxRange += CurrentActiveUnit.Boosts.RangeModifier;
                }

                //Select a target.
                Info.Map.TargetPlayerIndex = Target.Item1;
                Info.Map.TargetSquadIndex  = Target.Item2;
                float DistanceUnit = Math.Abs(ActiveSquadPosition.X - TargetSquad.X) + Math.Abs(ActiveSquadPosition.Y - TargetSquad.Y);
                //Move to be in range.

                List <Vector3> ListRealChoice = new List <Vector3>();

                foreach (MovementAlgorithmTile ActiveTerrain in Info.Map.GetMVChoice(Info.ActiveSquad))
                {
                    ListRealChoice.Add(new Vector3(ActiveTerrain.Position.X, ActiveTerrain.Position.Y, ActiveTerrain.LayerIndex));
                }
                for (int M = 0; M < ListRealChoice.Count; M++)
                {//Remove every MV that would make it impossible to attack.
                    float Distance = Math.Abs(ListRealChoice[M].X - TargetSquad.X) + Math.Abs(ListRealChoice[M].Y - TargetSquad.Y);
                    //Check if you can attack it if you moved.
                    if (Distance < MinRange || Distance > MaxRange)
                    {
                        ListRealChoice.RemoveAt(M--);
                    }
                }

                ListRealChoice = FilterMVChoice(ListRealChoice);
                //Must find a spot to move if got there, just to make sure it won't crash in case of logic error.
                if (ListRealChoice.Count != 0)
                {
                    int Choice = RandomHelper.Next(ListRealChoice.Count);

                    //Movement initialisation.
                    Info.Map.MovementAnimation.Add(Info.ActiveSquad.X, Info.ActiveSquad.Y, Info.ActiveSquad);

                    //Prepare the Cursor to move.
                    Info.Map.CursorPosition.X = ListRealChoice[Choice].X;
                    Info.Map.CursorPosition.Y = ListRealChoice[Choice].Y;
                    Info.ActiveSquad.SetPosition(ListRealChoice[Choice]);

                    Info.Map.FinalizeMovement(Info.ActiveSquad, (int)Info.Map.GetTerrain(Info.ActiveSquad).MovementCost);
                }
                else
                {
                    //Something is blocking the path.
                    Info.Map.FinalizeMovement(Info.ActiveSquad, 1);
                }
            }
コード例 #31
0
 public void SetSquad(Squad _squad)
 {
     squad = _squad;
     Populate();
 }
コード例 #32
0
        void IGameSaveTraitData.ResolveTraitData(Actor self, List <MiniYamlNode> data)
        {
            if (self.World.IsReplay)
            {
                return;
            }

            var initialBaseCenterNode = data.FirstOrDefault(n => n.Key == "InitialBaseCenter");

            if (initialBaseCenterNode != null)
            {
                initialBaseCenter = FieldLoader.GetValue <CPos>("InitialBaseCenter", initialBaseCenterNode.Value.Value);
            }

            var unitsHangingAroundTheBaseNode = data.FirstOrDefault(n => n.Key == "UnitsHangingAroundTheBase");

            if (unitsHangingAroundTheBaseNode != null)
            {
                unitsHangingAroundTheBase.Clear();
                unitsHangingAroundTheBase.AddRange(FieldLoader.GetValue <uint[]>("UnitsHangingAroundTheBase", unitsHangingAroundTheBaseNode.Value.Value)
                                                   .Select(a => self.World.GetActorById(a)).Where(a => a != null));
            }

            var activeUnitsNode = data.FirstOrDefault(n => n.Key == "ActiveUnits");

            if (activeUnitsNode != null)
            {
                activeUnits.Clear();
                activeUnits.AddRange(FieldLoader.GetValue <uint[]>("ActiveUnits", activeUnitsNode.Value.Value)
                                     .Select(a => self.World.GetActorById(a)).Where(a => a != null));
            }

            var rushTicksNode = data.FirstOrDefault(n => n.Key == "RushTicks");

            if (rushTicksNode != null)
            {
                rushTicks = FieldLoader.GetValue <int>("RushTicks", rushTicksNode.Value.Value);
            }

            var assignRolesTicksNode = data.FirstOrDefault(n => n.Key == "AssignRolesTicks");

            if (assignRolesTicksNode != null)
            {
                assignRolesTicks = FieldLoader.GetValue <int>("AssignRolesTicks", assignRolesTicksNode.Value.Value);
            }

            var attackForceTicksNode = data.FirstOrDefault(n => n.Key == "AttackForceTicks");

            if (attackForceTicksNode != null)
            {
                attackForceTicks = FieldLoader.GetValue <int>("AttackForceTicks", attackForceTicksNode.Value.Value);
            }

            var minAttackForceDelayTicksNode = data.FirstOrDefault(n => n.Key == "MinAttackForceDelayTicks");

            if (minAttackForceDelayTicksNode != null)
            {
                minAttackForceDelayTicks = FieldLoader.GetValue <int>("MinAttackForceDelayTicks", minAttackForceDelayTicksNode.Value.Value);
            }

            var squadsNode = data.FirstOrDefault(n => n.Key == "Squads");

            if (squadsNode != null)
            {
                Squads.Clear();
                foreach (var n in squadsNode.Value.Nodes)
                {
                    Squads.Add(Squad.Deserialize(bot, this, n.Value));
                }
            }
        }
コード例 #33
0
    public new void Add(Squad s)
    {
        base.Add(s.transform);

        s.cluster = this;
    }
コード例 #34
0
        protected void InitMemberList()
        {
            this.squadMemberGrid = this.screen.GetElement <UXGrid>("MemberGrid");
            this.squadMemberGrid.SetTemplateItem("MemberItem");
            this.squadMemberGrid.BypassLocalPositionOnAdd = true;
            this.squadMemberGrid.DupeOrdersAllowed        = true;
            this.squadMemberGrid.RepositionCallback       = new Action(this.RepositionFinished);
            this.squadMemberGrid.SetSortModeCustom();
            UXLabel element = this.screen.GetElement <UXLabel>("LabelMemberTitle");

            element.Text             = this.lang.Get("SQUAD_MEMBERS", new object[0]);
            this.memberSortMedalsBtn = this.screen.GetElement <UXCheckbox>("BtnMedals");
            this.SetupMemberSortButton(this.memberSortMedalsBtn, SquadMemberSortType.Medals);
            this.memberSortAttacksBtn = this.screen.GetElement <UXCheckbox>("BtnAttacksWon");
            this.SetupMemberSortButton(this.memberSortAttacksBtn, SquadMemberSortType.Attacks);
            this.memberSortDefensesBtn = this.screen.GetElement <UXCheckbox>("BtnDefensesWon");
            this.SetupMemberSortButton(this.memberSortDefensesBtn, SquadMemberSortType.Defenses);
            this.memberSortDontatedBtn = this.screen.GetElement <UXCheckbox>("BtnDonated");
            this.SetupMemberSortButton(this.memberSortDontatedBtn, SquadMemberSortType.Donated);
            this.memberSortReceivedBtn = this.screen.GetElement <UXCheckbox>("BtnReceived");
            this.SetupMemberSortButton(this.memberSortReceivedBtn, SquadMemberSortType.Received);
            this.memberSortActiveBtn = this.screen.GetElement <UXCheckbox>("BtnLastActive");
            this.SetupMemberSortButton(this.memberSortActiveBtn, SquadMemberSortType.Active);
            this.memberSortBox                = this.screen.GetElement <UXElement>("MemberFilterOptions");
            this.memberSortBox.Visible        = false;
            this.memberSortBtn                = this.screen.GetElement <UXButton>("BtnFilterMembers");
            this.memberSortBtn.OnClicked      = new UXButtonClickedDelegate(this.OnMemberSortOpenClicked);
            this.memberSortLabel              = this.screen.GetElement <UXLabel>("LabelBtnFilterMembers");
            this.groupStartWarBtns            = this.screen.GetElement <UXElement>("GroupStartWarBtns");
            this.btnStartWarConfirm           = this.screen.GetElement <UXButton>("BtnStartWarConfirm");
            this.btnStartWarConfirm.OnClicked = new UXButtonClickedDelegate(this.OnStartWarConfirm);
            this.btnCancelStartWar            = this.screen.GetElement <UXButton>("BtnCancelStartWar");
            this.btnCancelStartWar.OnClicked  = new UXButtonClickedDelegate(this.OnCancelStartWar);
            this.labelStartWarSelected        = this.screen.GetElement <UXLabel>("LabelStartWarSelected");
            this.labelBtnStartWarConfirm      = this.screen.GetElement <UXLabel>("LabelBtnStartWarConfirm");
            this.labelBtnStartWarConfirm.Text = this.lang.Get("WAR_LOOK_FOR_MATCH", new object[0]);
            this.labelBtnCancelStartWar       = this.screen.GetElement <UXLabel>("LabelBtnCancelStartWar");
            this.labelBtnCancelStartWar.Text  = this.lang.Get("CANCEL", new object[0]);
            this.curSortType = SquadMemberSortType.Medals;
            SquadController squadController = Service.SquadController;
            Squad           currentSquad    = squadController.StateManager.GetCurrentSquad();
            bool            flag            = currentSquad.Faction == FactionType.Empire;

            this.btnSameFaction               = this.screen.GetElement <UXButton>("BtnSameFactionMM");
            this.btnSameFaction.OnClicked     = new UXButtonClickedDelegate(this.OnSameFaction);
            this.btnInfoSameFaction           = this.screen.GetElement <UXButton>("BtnInfoSameFactionMM");
            this.btnInfoSameFaction.OnClicked = new UXButtonClickedDelegate(this.OnSameFactionInfo);
            string text;

            if (flag)
            {
                text = Service.Lang.Get("WAR_SAME_FACTION_CHECK_E", new object[0]);
            }
            else
            {
                text = Service.Lang.Get("WAR_SAME_FACTION_CHECK_R", new object[0]);
            }
            this.spriteCheckSameFaction         = this.screen.GetElement <UXSprite>("SpriteCheckBtnSameFactionMM");
            this.spriteCheckSameFaction.Visible = this.allowSameFaction;
            this.labelSameFaction      = this.screen.GetElement <UXLabel>("LabelSameFactionMM");
            this.labelSameFaction.Text = text;
            if (!GameConstants.WAR_ALLOW_SAME_FACTION_MATCHMAKING)
            {
                UXElement element2 = this.screen.GetElement <UXElement>("GroupSameFactionMM");
                element2.Visible = false;
            }
        }
コード例 #35
0
 public ActionPanelTransformPickUnit(DeathmatchMap Map, int ActivePlayerIndex, Squad ActiveSquad, bool ShowSquadMembers)
     : base(PanelName, Map)
 {
     this.ActivePlayerIndex = ActivePlayerIndex;
     this.ActiveSquad       = ActiveSquad;
     this.ShowSquadMembers  = ShowSquadMembers;
 }
コード例 #36
0
        public void SquadsAlgorithmTest()
        {
            Squad testSquad = _squadsAlgorithm.CombineSingleSquad(2, _exampleList, _asdList);

            Assert.AreEqual(2, testSquad.Players.Count());
        }
コード例 #37
0
 public override void OnTurnEnd(int ActivePlayerIndex, Squad ActiveSquad)
 {
 }
コード例 #38
0
        private void InitMarkers(AnimationLayer ActiveLayer, Squad AttackingSquad, Squad EnemySquad)
        {
            Unit ActiveUnit = AttackingSquad.CurrentLeader;
            Unit EnemyUnit  = EnemySquad.CurrentLeader;

            foreach (List <Timeline> ListActiveEvent in ActiveLayer.DicTimelineEvent.Values)
            {
                foreach (Timeline ActiveTimeline in ListActiveEvent)
                {
                    MarkerTimeline ActiveMarkerEvent = ActiveTimeline as MarkerTimeline;
                    if (ActiveMarkerEvent == null)
                    {
                        continue;
                    }

                    string AnimationPath;

                    switch (ActiveMarkerEvent.MarkerType)
                    {
                    case "Support Stand":
                    case "Support Standing":
                    case "Enemy Standing":
                    case "Enemy Stand":
                    case "Enemy Default":
                        ActiveMarkerEvent.AnimationMarker = new AnimationClass(EnemyUnit.Animations.Default.AnimationName);

                        ActiveMarkerEvent.AnimationMarker.DicTimeline = DicTimeline;
                        ActiveMarkerEvent.AnimationMarker.Load();

                        for (int L = ActiveMarkerEvent.AnimationMarker.ListAnimationLayer.Count - 1; L >= 0; --L)
                        {
                            InitMarkers(ActiveMarkerEvent.AnimationMarker.ListAnimationLayer[L], EnemySquad, AttackingSquad);
                        }
                        break;

                    case "Enemy Wingman A Standing":
                    case "Enemy Wingman 1 Standing":
                        if (EnemySquad.CurrentWingmanA != null)
                        {
                            ActiveMarkerEvent.AnimationMarker = new AnimationClass(EnemySquad.CurrentWingmanA.Animations.Default.AnimationName);

                            ActiveMarkerEvent.AnimationMarker.DicTimeline = DicTimeline;
                            ActiveMarkerEvent.AnimationMarker.Load();

                            for (int L = ActiveMarkerEvent.AnimationMarker.ListAnimationLayer.Count - 1; L >= 0; --L)
                            {
                                InitMarkers(ActiveMarkerEvent.AnimationMarker.ListAnimationLayer[L], EnemySquad, AttackingSquad);
                            }
                        }
                        break;

                    case "Enemy Wingman B Standing":
                    case "Enemy Wingman 2 Standing":
                        if (EnemySquad.CurrentWingmanB != null)
                        {
                            ActiveMarkerEvent.AnimationMarker = new AnimationClass(EnemySquad.CurrentWingmanB.Animations.Default.AnimationName);

                            ActiveMarkerEvent.AnimationMarker.DicTimeline = DicTimeline;
                            ActiveMarkerEvent.AnimationMarker.Load();

                            for (int L = ActiveMarkerEvent.AnimationMarker.ListAnimationLayer.Count - 1; L >= 0; --L)
                            {
                                InitMarkers(ActiveMarkerEvent.AnimationMarker.ListAnimationLayer[L], EnemySquad, AttackingSquad);
                            }
                        }
                        break;

                    case "Enemy Hit":
                        if (BattleResult.ArrayResult[0].AttackMissed)
                        {
                            AnimationPath = EnemyUnit.Animations.Default.AnimationName;
                        }
                        else
                        {
                            AnimationPath = EnemyUnit.Animations.Hit.AnimationName;
                        }
                        if (File.Exists("Content/Animations/" + AnimationPath + ".pea"))
                        {
                            ActiveMarkerEvent.AnimationMarker = new AnimationClass(AnimationPath);
                        }
                        else
                        {
                            ActiveMarkerEvent.AnimationMarker = new AnimationClass(EnemyUnit.Animations.Default.AnimationName);
                        }

                        ActiveMarkerEvent.AnimationMarker.DicTimeline = DicTimeline;
                        ActiveMarkerEvent.AnimationMarker.Load();

                        for (int L = ActiveMarkerEvent.AnimationMarker.ListAnimationLayer.Count - 1; L >= 0; --L)
                        {
                            InitMarkers(ActiveMarkerEvent.AnimationMarker.ListAnimationLayer[L], EnemySquad, AttackingSquad);
                        }
                        break;

                    case "Player Stand":
                    case "Player Standing":
                    case "Player Default":
                        ActiveMarkerEvent.AnimationMarker = new AnimationClass(ActiveUnit.Animations.Default.AnimationName);

                        ActiveMarkerEvent.AnimationMarker.DicTimeline = DicTimeline;
                        ActiveMarkerEvent.AnimationMarker.Load();

                        for (int L = ActiveMarkerEvent.AnimationMarker.ListAnimationLayer.Count - 1; L >= 0; --L)
                        {
                            InitMarkers(ActiveMarkerEvent.AnimationMarker.ListAnimationLayer[L], AttackingSquad, EnemySquad);
                        }
                        break;

                    default:
                        AnimationPath = EnemyUnit.Animations.Default.AnimationName;
                        if (ActiveMarkerEvent.MarkerType.StartsWith("Player "))
                        {
                            AnimationPath = ActiveMarkerEvent.MarkerType.Split(new string[] { "Player " }, StringSplitOptions.RemoveEmptyEntries)[0];
                        }
                        ActiveMarkerEvent.AnimationMarker = new AnimationClass(AnimationPath);

                        ActiveMarkerEvent.AnimationMarker.DicTimeline = DicTimeline;
                        ActiveMarkerEvent.AnimationMarker.Load();

                        for (int L = ActiveMarkerEvent.AnimationMarker.ListAnimationLayer.Count - 1; L >= 0; --L)
                        {
                            InitMarkers(ActiveMarkerEvent.AnimationMarker.ListAnimationLayer[L], AttackingSquad, EnemySquad);
                        }
                        break;
                    }
                }
            }
        }
コード例 #39
0
    public void Init(Vector2 positionOfTarget, Damage damage, float distance, float speed, int countOfPilumsToVolley, Squad owner = null, Action <int, Squad> callbackUsedCount = null)
    {
        //кол-во юнитов отряде. - то есть и кол во пилумов в залпе
        int countOfUnits = 30;

        if (owner != null)
        {
            countOfUnits = owner.UnitCount;
        }

        if (countOfPilumsToVolley > countOfUnits)
        {
            countPilumsInValley = countOfUnits;
        }
        else
        {
            countPilumsInValley = countOfPilumsToVolley;
        }

        this.owner = owner;

        //ширина строя  (скорее всего надо будет потом переделать. т.к. хочу в будущем переделать построения)
        int rowLength = owner.SQUAD_LENGTH;

        if (rowLength > countOfUnits)
        {
            rowLength = countOfUnits;
        }

        //макс кол-во пилумов
        var main = pSys.main;

        main.maxParticles = countPilumsInValley;

        //ставим наальную скорость в 0, так как контролировать скорость будем через velocityOverLifetime
        var ss = main.startSpeed;

        ss.constant     = 0;
        main.startSpeed = ss;

        //длительность жисзни частиц и проигрывания анимации. для соответствия указанной дальности полёта пилумов
        var lt = main.startLifetime;

        lt.constant        = distance / speed;
        main.startLifetime = lt;
        main.duration      = main.startLifetime.constant;

        //ширина появления пилумов
        var shape = pSys.shape;

        shape.radius = rowLength / 2f;

        //направление полета пилумов. чтоб можно было не только впереди строя кидать, но и в бок
        var velosOvT = pSys.velocityOverLifetime;

        velosOvT.enabled = true;
        velosOvT.space   = ParticleSystemSimulationSpace.World;

        var x = velosOvT.x;
        var y = velosOvT.y;

        var angle = positionOfTarget - (Vector2)transform.position;

        angle = angle.normalized * speed;

        x.constant = angle.x;
        y.constant = angle.y;

        velosOvT.x = x;
        velosOvT.y = y;

        //чтоб самаго себя не бил убираем колизию свого слоя
        var collis = pSys.collision;

        mask                = collis.collidesWith;
        mask.value          = mask.value & ~(1 << LayerMask.NameToLayer(owner.fraction.ToString()));
        collis.collidesWith = mask;

        this.damage = damage;

        CallbackUsedCount = callbackUsedCount;
    }
コード例 #40
0
 public ActionPanelFly(DeathmatchMap Map, Squad ActiveSquad)
     : base("Fly", Map)
 {
     this.ActiveSquad = ActiveSquad;
 }
コード例 #41
0
ファイル: ProtectionStates.cs プロジェクト: wytsep/OpenRA
 public void Deactivate(Squad owner)
 {
     owner.units.Clear();
 }
コード例 #42
0
ファイル: SquadRangeCollider.cs プロジェクト: EunoiaGames/MTW
 public void Awake()
 {
     _parent = GetComponentInParent<Squad>();
 }
コード例 #43
0
    public override Vector3 CalculateMove(SquadUnit squadUnit, List <Transform> context, Squad squad)
    {
        Vector3 followPathVector = Vector3.zero;

        followPathVector = squadUnit.TargetTransform.position - squadUnit.PathTransform.position;

        return(followPathVector);
    }
コード例 #44
0
 public static void DefaultBehaviour(Squad squad)
 {
     RandomBehavior(squad);
 }
コード例 #45
0
 public void Update(Squad squad)
 {
     currentState.Tick(squad);
 }
コード例 #46
0
 public async Task DeleteAsync(Squad squad)
 {
     _squadRepository.Remove(squad);
     await _unitOfWork.CompleteAsync();
 }
コード例 #47
0
 public async Task CreateAsync(Squad squad)
 {
     _squadRepository.Add(squad);
     await _unitOfWork.CompleteAsync();
 }
コード例 #48
0
        public int WeaponIndexOld;//Index of the weapon used for reset.

        #endregion

        public bool CanNullifyAttack(Attack ActiveWeapon, string AttackerMovementType, string DefenderMovementType, Squad DefenderSquad, StatsBoosts DefenderBoosts)
        {
            //Check if the Unit can counter the attack.
            bool NullifyAttack = false;

            if (ActiveWeapon.DicTerrainAttribute["Sea"] == '-' &&
                (DefenderMovementType == "Sea" ||
                 AttackerMovementType == "Sea"))
            {
                NullifyAttack = true;
            }
            else if (DefenderBoosts.ParryModifier.Contains(ActiveWeapon.FullName) || DefenderBoosts.NullifyDamageModifier)
            {
                NullifyAttack = true;
            }
            else if (DefenderSquad != null)
            {
                for (int U = DefenderSquad.UnitsAliveInSquad - 1; U >= 0 && !NullifyAttack; --U)
                {
                    if (DefenderSquad[U].Boosts.NullifyAttackModifier.Contains(ActiveWeapon.FullName))
                    {
                        NullifyAttack = true;
                    }
                }
            }
            return(NullifyAttack);
        }
コード例 #49
0
        public void ActivateAutomaticSkills(Squad ActiveSquad, Unit ActiveUnit, string SkillRequirementToActivate, Squad TargetSquad, Unit TargetUnit)
        {
            Character TargetPilot;

            if (TargetUnit != null)
            {
                TargetPilot = TargetUnit.Pilot;
            }
            else
            {
                TargetPilot = null;
            }

            GlobalBattleContext.SetContext(ActiveSquad, ActiveUnit, null, TargetSquad, TargetUnit, TargetPilot, ActiveParser);

            // Character Skills
            for (int C = 0; C < ActiveUnit.ArrayCharacterActive.Length; C++)
            {
                GlobalBattleContext.SetContext(ActiveSquad, ActiveUnit, ActiveUnit.ArrayCharacterActive[C], TargetSquad, TargetUnit, TargetPilot, ActiveParser);

                for (int S = 0; S < ActiveUnit.ArrayCharacterActive[C].ArrayPilotSkill.Length; S++)
                {
                    BaseAutomaticSkill ActiveSkill = ActiveUnit.ArrayCharacterActive[C].ArrayPilotSkill[S];
                    ActiveSkill.AddSkillEffectsToTarget(SkillRequirementToActivate);
                }

                for (int S = 0; S < ActiveUnit.ArrayCharacterActive[C].ArrayRelationshipBonus.Length; S++)
                {
                    BaseAutomaticSkill ActiveSkill = ActiveUnit.ArrayCharacterActive[C].ArrayRelationshipBonus[S];
                    ActiveSkill.AddSkillEffectsToTarget(SkillRequirementToActivate);
                }
            }

            GlobalBattleContext.SetContext(ActiveSquad, ActiveUnit, ActiveUnit.Pilot, TargetSquad, TargetUnit, TargetPilot, ActiveParser);

            // Unit Abilities
            for (int S = 0; S < ActiveUnit.ArrayUnitAbility.Length; S++)
            {
                BaseAutomaticSkill ActiveSkill = ActiveUnit.ArrayUnitAbility[S];
                ActiveSkill.AddSkillEffectsToTarget(SkillRequirementToActivate);
            }

            // Attack Attributes
            if (ActiveUnit.CurrentAttack != null)
            {
                for (int S = 0; S < ActiveUnit.CurrentAttack.ArrayAttackAttributes.Length; S++)
                {
                    BaseAutomaticSkill ActiveSkill = ActiveUnit.CurrentAttack.ArrayAttackAttributes[S];
                    ActiveSkill.AddSkillEffectsToTarget(SkillRequirementToActivate);
                }
            }

            //Reset active effects in case an effect was removed.
            ActiveUnit.ReactivateEffects();

            GlobalBattleContext.SetContext(null, null, null, TargetSquad, TargetUnit, TargetPilot, ActiveParser);
        }
コード例 #50
0
 public async Task UpdateAsync(Squad squad)
 {
     await _unitOfWork.CompleteAsync();
 }
コード例 #51
0
 public ActionPanelTransform(DeathmatchMap Map, int ActivePlayerIndex, Squad ActiveSquad)
     : base(PanelName, Map)
 {
     this.ActivePlayerIndex = ActivePlayerIndex;
     this.ActiveSquad       = ActiveSquad;
 }
コード例 #52
0
        public static bool EvaluateAudienceCondition(AudienceCondition ac)
        {
            Squad  currentSquad  = Service.SquadController.StateManager.GetCurrentSquad();
            string playerId      = Service.CurrentPlayer.PlayerId;
            string conditionType = ac.ConditionType;

            switch (conditionType)
            {
            case "playerInSquadWar":
            {
                bool flag = ac.ConditionValue.ToLower() == "true";
                if (currentSquad != null)
                {
                    SquadMember squadMemberById = SquadUtils.GetSquadMemberById(currentSquad, playerId);
                    if (squadMemberById != null)
                    {
                        SquadWarManager warManager = Service.SquadController.WarManager;
                        return(warManager.IsSquadMemberInWarOrMatchmaking(squadMemberById) == flag);
                    }
                }
                return(false);
            }

            case "squadWarParticipation":
            {
                uint num2       = Convert.ToUInt32(ac.ConditionValue) * 3600u;
                int  serverTime = (int)Service.ServerAPI.ServerTime;
                return((long)serverTime - (long)((ulong)Service.CurrentPlayer.LastWarParticipationTime) >= (long)((ulong)num2));
            }

            case "squadActiveMembers":
            case "squadMembers":
            {
                string[] array = ac.ConditionValue.Split(new char[]
                    {
                        '|'
                    });
                if (array == null || array.Length != 2)
                {
                    Service.Logger.Error("Data error for SQUAD_MEMBER_CONDITION");
                    return(false);
                }
                int num3 = int.Parse(array[0]);
                int num4 = int.Parse(array[1]);
                if (currentSquad == null && num4 == 0)
                {
                    return(true);
                }
                if (currentSquad != null)
                {
                    if (ac.ConditionType == "squadMembers" && currentSquad.MemberCount >= num3 && currentSquad.MemberCount <= num4)
                    {
                        return(true);
                    }
                    if (ac.ConditionType == "squadActiveMembers" && currentSquad.ActiveMemberCount >= num3 && currentSquad.ActiveMemberCount <= num4)
                    {
                        return(true);
                    }
                }
                return(false);
            }

            case "hasCountry":
            {
                string   deviceCountryCode = Service.EnvironmentController.GetDeviceCountryCode();
                string[] array2            = ac.ConditionValue.Split(new char[]
                    {
                        '|'
                    });
                if (Array.IndexOf <string>(array2, deviceCountryCode) == -1)
                {
                    return(false);
                }
                break;
            }

            case "lacksCountry":
            {
                string   deviceCountryCode2 = Service.EnvironmentController.GetDeviceCountryCode();
                string[] array3             = ac.ConditionValue.Split(new char[]
                    {
                        '|'
                    });
                if (Array.IndexOf <string>(array3, deviceCountryCode2) != -1)
                {
                    return(false);
                }
                break;
            }

            case "hasLanguage":
            {
                string   locale = Service.Lang.Locale;
                string[] array4 = ac.ConditionValue.Split(new char[]
                    {
                        '|'
                    });
                if (Array.IndexOf <string>(array4, locale) == -1)
                {
                    return(false);
                }
                break;
            }

            case "lacksLanguage":
            {
                string   locale2 = Service.Lang.Locale;
                string[] array5  = ac.ConditionValue.Split(new char[]
                    {
                        '|'
                    });
                if (Array.IndexOf <string>(array5, locale2) != -1)
                {
                    return(false);
                }
                break;
            }

            case "thirdParty":
                return(false);

            case "platform":
            {
                string[] array6 = ac.ConditionValue.Split(new char[]
                    {
                        '|'
                    });
                if (array6 != null)
                {
                    string[] array7 = array6;
                    for (int i = 0; i < array7.Length; i++)
                    {
                        string a = array7[i];
                        if (a == "a")
                        {
                            return(true);
                        }
                    }
                }
                return(false);
            }
            }
            return(true);
        }
コード例 #53
0
            public override void Update(Microsoft.Xna.Framework.GameTime gameTime)
            {
                Unit NewLeader   = null;
                Unit NewWingmanA = null;
                Unit NewWingmanB = null;

                List <Character> ListCharacterPresent = Map.PlayerRoster.TeamCharacters.GetPresent();

                List <Unit> ListUnitPresent = Map.PlayerRoster.TeamUnits.GetPresent();

                NewLeader = ListUnitPresent.Find(u => u.UnitTypeName + "\\" + u.RelativePath == _LeaderName);
                Map.PlayerRoster.TeamUnits.Remove(NewLeader);

                NewLeader.ArrayCharacterActive = new Character[_LeaderCharacterName.Length];
                for (int C = 0; C < _LeaderCharacterName.Length; C++)
                {
                    NewLeader.ArrayCharacterActive[C] = ListCharacterPresent.Find(c => c.FullName == _LeaderCharacterName[C]);
                    Map.PlayerRoster.TeamCharacters.Remove(NewLeader.ArrayCharacterActive[C]);
                }

                if (!string.IsNullOrEmpty(_WingmanAName))
                {
                    NewWingmanA = ListUnitPresent.Find(u => u.UnitTypeName + "\\" + u.RelativePath == _WingmanAName);
                    Map.PlayerRoster.TeamUnits.Remove(NewWingmanA);

                    NewWingmanA.ArrayCharacterActive = new Character[_WingmanACharacterName.Length];
                    for (int C = 0; C < _WingmanACharacterName.Length; C++)
                    {
                        NewWingmanA.ArrayCharacterActive[C] = ListCharacterPresent.Find(c => c.FullName == _WingmanACharacterName[C]);
                        Map.PlayerRoster.TeamCharacters.Remove(NewWingmanA.ArrayCharacterActive[C]);
                    }
                }

                if (!string.IsNullOrEmpty(_WingmanBName))
                {
                    NewWingmanB = ListUnitPresent.Find(u => u.UnitTypeName + "\\" + u.RelativePath == _WingmanBName);
                    Map.PlayerRoster.TeamUnits.Remove(NewWingmanB);

                    NewWingmanB.ArrayCharacterActive = new Character[_WingmanBCharacterName.Length];
                    for (int C = 0; C < _WingmanBCharacterName.Length; C++)
                    {
                        NewWingmanB.ArrayCharacterActive[C] = ListCharacterPresent.Find(c => c.FullName == _WingmanBCharacterName[C]);
                        Map.PlayerRoster.TeamCharacters.Remove(NewWingmanB.ArrayCharacterActive[C]);
                    }
                }

                Squad NewSquad = new Squad(_SquadName, NewLeader, NewWingmanA, NewWingmanB);

                NewSquad.IsEventSquad     = _IsEventSquad;
                NewSquad.IsNameLocked     = _IsNameLocked;
                NewSquad.IsLeaderLocked   = _IsLeaderLocked;
                NewSquad.IsWingmanALocked = _IsWingmanALocked;
                NewSquad.IsWingmanBLocked = _IsWingmanBLocked;

                if (_IsPresent)
                {
                    NewSquad.TeamTags.AddTag("Present");
                }
                if (_IsEvent)
                {
                    NewSquad.TeamTags.AddTag("Event");
                }

                Map.PlayerRoster.TeamSquads.Add(NewSquad);

                ExecuteEvent(this, 0);
                IsEnded = true;
            }
コード例 #54
0
 // Update is called once per frame
 void Update()
 {
     _squad_selected = ClickManager.Instance.squad_selected;
 }
コード例 #55
0
 public override List <ActionPanel> OnMenuMovement(int ActivePlayerIndex, Squad ActiveSquad, ActionPanelHolder ListActionMenuChoice)
 {
     return(null);
 }
コード例 #56
0
 public void RevertToPreviousState(Squad squad, bool saveCurrentState)
 {
     ChangeState(squad, previousState, saveCurrentState);
 }
コード例 #57
0
 public ActionPanelDive(DeathmatchMap Map, Squad ActiveSquad)
     : base(PanelName, Map)
 {
     this.ActiveSquad = ActiveSquad;
 }
コード例 #58
0
        public AnimationScreen(string AnimationPath, DeathmatchMap Map, Squad AttackingSquad, Squad EnemySquad, Attack ActiveAttack,
                               BattleMap.SquadBattleResult BattleResult, AnimationUnitStats UnitStats, AnimationBackground ActiveAnimationBackground, AnimationBackground ActiveAnimationForeground, string ExtraText, bool IsLeftAttacking)
            : base(AnimationPath)
        {
            RequireFocus     = false;
            RequireDrawFocus = false;
            IsOnTop          = false;
            Random           = new Random();
            IsLoaded         = false;

            this.Map                       = Map;
            this.AttackingSquad            = AttackingSquad;
            this.EnemySquad                = EnemySquad;
            this.ActiveAttack              = ActiveAttack;
            this.BattleResult              = BattleResult;
            this.UnitStats                 = UnitStats;
            this.ActiveAnimationBackground = ActiveAnimationBackground;
            this.ActiveAnimationForeground = ActiveAnimationForeground;
            this.ExtraText                 = ExtraText;
            this.IsLeftAttacking           = IsLeftAttacking;

            RightSquad = AttackingSquad;
            LeftSquad  = EnemySquad;

            if (IsLeftAttacking)
            {
                RightSquad = EnemySquad;
                LeftSquad  = AttackingSquad;
            }
        }
コード例 #59
0
 public void SetSquad(Squad squad)
 {
     this.squad = squad;
 }
コード例 #60
0
ファイル: ProtectionStates.cs プロジェクト: wytsep/OpenRA
 public void Activate(Squad owner)
 {
 }