Example #1
0
        }                                                                 //get the current attack power.

        public void UpdateCurrentAttackPower(Unit unit, bool add)
        {
            //get the base attack component:
            if (unit.AttackComp == null)
            {
                return;
            }

            AttackEntity baseAttack = (unit.MultipleAttackMgr != null) ? unit.MultipleAttackMgr.AttackEntities[unit.MultipleAttackMgr.BasicAttackID] : unit.AttackComp;

            //add/remove attack power:
            currentAttackPower += ((add == true) ? (1) : (-1)) * baseAttack.GetAttackPower();
        }
Example #2
0
            //a method that launches the attack object towards the target
            public void Launch(EffectObjPool effectPool, AttackEntity source)
            {
                AttackObject newAttackObject = effectPool.SpawnEffectObj(attackObject, launchPosition.position, Quaternion.identity).GetComponent <AttackObject>();

                Vector3 targetPosition = source.GetTargetPosition();

                if (GameManager.MultiplayerGame == false) //if this is a singleplayer game, we can play with accuracy:
                {
                    targetPosition += new Vector3(Random.Range(-accuracyModifier.x, accuracyModifier.x), Random.Range(-accuracyModifier.y, accuracyModifier.y), Random.Range(-accuracyModifier.z, accuracyModifier.z));
                }

                newAttackObject.Enable(source, targetPosition,
                                       (createInDelay == true) ? delayTime : 0.0f,
                                       damageInDelay,
                                       delayParentObject,
                                       source.CanEngageFriendly());
            }
Example #3
0
 public abstract void UpdateAttackComp(AttackEntity attackEntity);
Example #4
0
 private UnitAttack[] AllAttackComp = new UnitAttack[0]; //holds all of the attack components attached to this unit
 public override void UpdateAttackComp(AttackEntity attackEntity)
 {
     AttackComp = (UnitAttack)attackEntity;
 }
Example #5
0
 private BuildingAttack[] AllAttackComp = new BuildingAttack[0]; //holds all of the attack components attached to this unit
 public override void UpdateAttackComp(AttackEntity attackEntity)
 {
     AttackComp = (BuildingAttack)attackEntity;
 }
Example #6
0
        //update the task panel:
        public void Update()
        {
            Hide();                                                                                                                                          //hide currently active tasks

            List <Unit>     selectedUnits     = gameMgr.SelectionMgr.Selected.GetEntitiesList(EntityTypes.unit, false, true).Cast <Unit>().ToList();         //get selected units from player faction
            List <Building> selectedBuildings = gameMgr.SelectionMgr.Selected.GetEntitiesList(EntityTypes.building, false, true).Cast <Building>().ToList(); //get selected buildings from player faction

            if (selectedUnits.Count + selectedBuildings.Count == 1)                                                                                          //if only one faction entity is selected
            {
                FactionEntity factionEntity = selectedUnits.Count == 1 ? selectedUnits[0] as FactionEntity : selectedBuildings[0] as FactionEntity;          //get it

                if (factionEntity.EntityHealthComp.IsDead() == true)                                                                                         //if dead, then do not show any tasks
                {
                    return;
                }

                UpdateAPCTasks(factionEntity, factionEntity.APCComp);                      //show APC tasks only if one faction entity is selected
                UpdateTaskLauncherTasks(factionEntity, factionEntity.TaskLauncherComp);    //show task launcher tasks only if one faction entity is selected
                UpdateMultipleAttackTasks(factionEntity, factionEntity.MultipleAttackMgr); //show the multiple attack component only if one faction entity is selected
            }

            AttackEntity attackComp = null;                                                                    //when != null, then all selected units/buildings have an attack component

            if (selectedBuildings.Count > 0)                                                                   //more than one building is selected
            {
                foreach (Building building in selectedBuildings)                                               //see if all buildings are placed and built and all have an attack component
                {
                    if (building.Placed == false || building.IsBuilt == false || building.HealthComp == false) //if one of the buildings is not built or placed
                    {
                        return;
                    }

                    attackComp = building.AttackComp;

                    if (attackComp == null) //no attack component detected here, do not continue
                    {
                        break;
                    }
                }

                if (selectedBuildings.Count == 1 && selectedUnits.Count == 0)                               //only one building selected
                {
                    UpdateResourceGeneratorTasks(selectedBuildings[0], selectedBuildings[0].GeneratorComp); //show the resource generator tasks
                }
            }

            if (selectedUnits.Count > 0) //units are selected
            {
                //see if all selected units have the following components
                Builder           builderComp   = selectedUnits[0].BuilderComp;
                ResourceCollector collectorComp = selectedUnits[0].CollectorComp;
                Healer            healerComp    = selectedUnits[0].HealerComp;
                Converter         converterComp = selectedUnits[0].ConverterComp;
                attackComp = selectedUnits[0].AttackComp;

                //make sure all selected units have the same components
                foreach (Unit u in selectedUnits)
                {
                    if (u.HealthComp.IsDead() == true) //if one of the unit is dead
                    {
                        return;                        //do not continue
                    }
                    if (u.BuilderComp == null)
                    {
                        builderComp = null;
                    }
                    if (u.CollectorComp == null)
                    {
                        collectorComp = null;
                    }
                    if (u.HealerComp == null)
                    {
                        healerComp = null;
                    }
                    if (u.ConverterComp == null)
                    {
                        converterComp = null;
                    }
                    if (u.AttackComp == null)
                    {
                        attackComp = null;
                    }
                }

                UpdateUnitComponentTask(selectedUnits[0], selectedUnits[0].MovementComp.taskUI, TaskTypes.movement);

                if (builderComp != null)
                {
                    UpdateUnitComponentTask(selectedUnits[0], builderComp.taskUI, TaskTypes.build);

                    if (selectedBuildings.Count == 0) //only if no buildings are selected can we show the buildings to place
                    {
                        UpdateBuilderTasks(selectedUnits[0], builderComp);
                    }
                }
                if (collectorComp != null)
                {
                    UpdateUnitComponentTask(selectedUnits[0], collectorComp.taskUI, TaskTypes.collectResource);
                }
                if (healerComp != null)
                {
                    UpdateUnitComponentTask(selectedUnits[0], healerComp.taskUI, TaskTypes.heal);
                }
                if (converterComp != null)
                {
                    UpdateUnitComponentTask(selectedUnits[0], converterComp.taskUI, TaskTypes.convert);
                }

                if (selectedUnits.Count == 1 && selectedBuildings.Count == 0) //if there's only one unit and no buildings selected
                {
                    UpdateWanderTasks(selectedUnits[0], selectedUnits[0].WanderComp);
                }
            }

            if (attackComp != null) //if all selected buildings and units have an attack component
            {
                UpdateUnitComponentTask(attackComp.FactionEntity, attackComp.taskUI, TaskTypes.attack);
            }
        }
Example #7
0
 //called to init the attack damage settings
 public void Init(GameManager gameMgr, AttackEntity attackEntity)
 {
     this.gameMgr = gameMgr;
     source       = attackEntity;
 }
Example #8
0
 public static void OnAttackDamageDealt(AttackEntity attackComp, FactionEntity target, int damage)
 {
     AttackDamageDealt(attackComp, target, damage);
 }
Example #9
0
 public static void OnAttackCooldownUpdated(AttackEntity attackComp, FactionEntity target)
 {
     AttackCooldownUpdated(attackComp, target, Vector3.zero);
 }
Example #10
0
 public static void OnAttackerInRange(AttackEntity attackComp, FactionEntity target, Vector3 targetPosition)
 {
     AttackerInRange(attackComp, target, targetPosition);
 }
Example #11
0
 public static void OnAttackPerformed(AttackEntity attackComp, FactionEntity target, Vector3 targetPosition)
 {
     AttackPerformed(attackComp, target, targetPosition);
 }
Example #12
0
 //Attack Switch:
 public static void OnAttackSwitch(AttackEntity attackComp)          //called when a unit switchs attack type:
 {
     AttackSwitch(attackComp, null, Vector3.zero);
 }
Example #13
0
 public void Init(GameManager gameMgr, AttackEntity source)
 {
     this.gameMgr = gameMgr;
     this.source  = source;
 }