示例#1
0
 public void EndPlayerTurn()
 {
     IsPlayerTurn = false;
     if (PlayerManager.Instance.Object != null && PlayerManager.Instance.Statistic != null)
     {
         var coroutine = EnemyUtils.EnemiesMove();
         StartCoroutine(coroutine);
     }
 }
示例#2
0
 // Create a controller if the data is valid
 public static SpawnController CreateController(EnemySpawnData spawnData, int id)
 {
     if (EnemyUtils.IsDataValid(spawnData))
     {
         SpawnController newController = new SpawnController();
         newController.data  = spawnData;
         newController.time  = 0f;
         newController.count = 0;
         newController.id    = id;
         //UnityEngine.Debug.Log("Creating spawn controller, " + spawnData.enemyId + ", time: " + spawnData.startSpawnTime + " - " + spawnData.endSpawnTime);
         return(newController);
     }
     return(null);
 }
示例#3
0
 public void KillEnemy(Enemy enemy)
 {
     try
     {
         List.Remove(enemy);
         LootManager.Instance.GenerateLoot(enemy.transform, enemy.Statistic);
         Destroy(enemy.gameObject);
         EnemyUtils.UnSelectAllEnemies();
     }
     catch (Exception)
     {
         Debug.Log("Enemy shouldn't be here!");
     }
 }
示例#4
0
    public void Update(EnemyHandler handler, float gameTime, float delta)
    {
        time += delta;
        if (EnemyUtils.CheckSpawnNeeded(data, gameTime, time, count))
        {
            // Ask the enemy handler to create new enemies
            time = 0f;
            int createEnemies = 1;
            if (count == 0)
            {
                createEnemies = data.startCount;
            }

            count += handler.SpawnEnemies(data, createEnemies, id);
        }
    }
示例#5
0
    public bool CheckHit(Vector3 heroPos, int hitId)
    {
        if (this.hitId == hitId || !IsAlive())
        {
            return(false);
        }

        // Hit id is used to allow one hero movement per hit
        // (since each update scans for hits, a hero moving across an enemy may trigger multiple hits.
        Vector3 pos = GetBodySpritePosition();

        if (EnemyUtils.CheckBoxHit(pos, heroPos, data.size))
        {
            if (EnemyUtils.CheckDistanceHit(pos, heroPos, data.size))
            {
                this.hitId = hitId;
                return(true);
            }
        }
        return(false);
    }
示例#6
0
        void FixedUpdate()
        {
            if (WindowManager.Instance == null)
            {
                return;
            }
            if (WindowManager.Instance.Status == WindowState.Close)
            {
                if (Input.GetKeyDown(InputManager.Instance.FightNormalKey))
                {
                    FightUtils.Instance.AttackEnemy();
                }
                if (Input.GetKeyDown(KeyCode.Mouse0))
                {
                    FightUtils.Instance.AttackEnemy();
                }

                if (Input.GetKeyDown(InputManager.Instance.FightSpecialKey))
                {
                    FightUtils.Instance.SpecialAttackEnemy();
                }
                if (Input.GetKeyDown(KeyCode.Mouse1))
                {
                    FightUtils.Instance.SpecialAttackEnemy();
                }

                if (Input.GetKeyDown(InputManager.Instance.SelectEnemyKey))
                {
                    EnemyUtils.SelectEnemy();
                }
                if (Input.GetKeyDown(InputManager.Instance.SelectSpecialAttackKey))
                {
                    PlayerManager.Instance.Statistic.SelectSpecialAttack();
                }
                if (Input.GetKeyDown(InputManager.Instance.ExitKey))
                {
                    EndGame();
                }
                if (Input.GetKeyDown(InputManager.Instance.OpenDetailWindowKey))
                {
                    WindowManager.Instance.Open(WindowType.Detail);
                }
                if (Input.GetKeyDown(InputManager.Instance.OpenEquipmentWindowKey))
                {
                    WindowManager.Instance.Open(WindowType.Equipment);
                }

                //   detectPressedKeyOrButton();
                if (UIManager.Instance != null)
                {
                    UIManager.Instance.Enabled = true;
                }
            }
            else
            {
                if (UIManager.Instance != null)
                {
                    UIManager.Instance.Enabled = false;
                }
            }
            if (EnemyUtils.SelectedEnemy != null && EnemyUtils.SelectedEnemy.Distance > 1)
            {
                EnemyUtils.UnSelectAllEnemies();
            }
        }
示例#7
0
 public void Awake()
 {
     EnemyCharacter = EnemyUtils.GenerateEnemy();
     _selectedLight = GetComponentInChildren <Light>();
     //    _target = GameObject.FindGameObjectWithTag(PlayerStatistic.Tag).transform;
 }
示例#8
0
 public void Awake()
 {
     Statistic      = EnemyUtils.GenerateEnemy();
     _selectedLight = GetComponentInChildren <Light>();
 }