Example #1
0
        public static void OrderMoveAggressively(Vector3 destination)
        {
            bool addToActionQueue = Input.GetKey(additiveKeycode);

            foreach (SelectionManager.SelectionGroup group in SelectionManager.Instance.SpartanGroups)
            {
                for (int j = 0; j < group.unitsSelected.Count; j++)
                {
                    var actionMoveAggressively = new ActionMoveToPositionAggressively(group.unitsSelected[j], destination);

                    group.unitsSelected[j].SetAction(actionMoveAggressively, addToActionQueue);
                }
            }

            OnOrderGiven?.Invoke();
            OnOrder_MoveAggressively?.Invoke(destination);
        }
Example #2
0
    private void MakeEntitiesGreatAgain()
    {
        //Debug.Log("MakeEntitiesGreatAgain, attack'll work at " + System.DateTime.Now.AddSeconds(ActionMoveToPositionAggressively.DELAY).ToLongTimeString());

        Entity[] entities = FindObjectsOfType <Entity>();

        int length = entities.Length;

        for (int i = 0; i < length; i++)
        {
            Entity entity = entities[i];

            // calculate position
            Vector3 position = entity.transform.position + GetOffset(entity.Team);

            // apply move to position method
            ActionMoveToPositionAggressively action = new ActionMoveToPositionAggressively(entity, position);
            entity.SetAction(action);
        }
    }
Example #3
0
        void SpawnUnit(GameObject prefab, Vector3 position, Transform attackTarget)
        {
            Assert.IsNotNull(prefab, debugLogHeader + " prefab of " + _entityID + " should be not null. Aborting unit sequence.");

            var instanciatedPrefab       = ObjectPooler.Instance.SpawnFromPool(prefab, RandomNavmeshLocation(position, 8f), Quaternion.identity, true);
            var instanciatedPrefabEntity = instanciatedPrefab.GetComponent <Entity>();

            Assert.IsNotNull(instanciatedPrefabEntity, string.Format("Unit {0} misses the Entity component", prefab.name));

            instanciatedPrefabEntity.Team = Team.Enemy;

            if (attackTarget != null)
            {
                // make unit go to temple
                Action action = new ActionMoveToPositionAggressively(instanciatedPrefabEntity, attackTarget.position);
                instanciatedPrefabEntity.SetAction(action);
            }
            else
            {
                Debug.LogErrorFormat(debugLogHeader + "No temple found. Can't make Unit move aggressively to it");
            }

            EntitySpawnFromWave?.Invoke(instanciatedPrefabEntity);
        }