Beispiel #1
0
 private bool ChargeMana(IPlayer player, IEnemy enemy, int enemyAttackChance, bool enemyCanAttack)
 {
     if (player.GetCurrentStats().AttackSpeed >= enemy.GetCurrentStats().AttackSpeed)
     {
         player.ChargeMana(enemy);
         if (enemyCanAttack)
         {
             enemy.Attack(enemyAttackChance % 2 == 0 && enemy.GetCurrentStats().CurrentMana >= enemy.GetCurrentStats().ManaCost, player);
             if (player.IsDefeated(enemy))
             {
                 Defeat();
                 return(true);
             }
         }
     }
     else
     {
         if (enemyCanAttack)
         {
             enemy.Attack(enemyAttackChance % 2 == 0 && enemy.GetCurrentStats().CurrentMana >= enemy.GetCurrentStats().ManaCost, player);
             if (player.IsDefeated(enemy))
             {
                 Defeat();
                 return(true);
             }
         }
         player.ChargeMana(enemy);
     }
     return(false);
 }
    private void FixedUpdate()
    {
        Vector3 normal = (player.transform.position - transform.position).normalized;

        if (move)
        {
            moveDir = normal;
            controller.Move(moveDir.x * speed * Time.fixedDeltaTime, moveDir.y * speed * Time.fixedDeltaTime);
        }
        else
        {
            controller.StopMove();
        }
        if (attack)
        {
            CraigController craig = player.GetComponent <CraigController>();
            if (craig.bulletTime)
            {
                controller.Attack(attackSpeed * craig.bulletTimeEffect);
            }
            else
            {
                controller.Attack(attackSpeed);
            }
            ResetAttack();
        }
        controller.Rotate(normal);
        moveDir = Vector3.zero;
        move    = false;
    }
Beispiel #3
0
        public static int Update(IPlayer mario, IEnemy enemy, Collision.CollisionType collisionType)
        {
            switch (collisionType)
            {
            case Collision.CollisionType.Above:
                enemy.TakeDamage();

                return((int)Enum.DisableMovementType.Down);

            case Collision.CollisionType.Below:

                enemy.Attack(mario);
                mario.Attack(enemy);
                return((int)Enum.DisableMovementType.Up);

            case Collision.CollisionType.Left:

                enemy.Attack(mario);
                mario.Attack(enemy);
                return((int)Enum.DisableMovementType.Right);

            case Collision.CollisionType.Right:

                enemy.Attack(mario);
                mario.Attack(enemy);
                return((int)Enum.DisableMovementType.Left);

            default:
                return((int)Enum.DisableMovementType.None);
            }
        }
Beispiel #4
0
    private void OnTriggerEnter2D(Collider2D col)
    {
        var o        = col.gameObject;
        var isPlayer = o == GameManager.Instance.player || o == GameManager.Instance.playerTrigger;

        if (isPlayer)
        {
            parentComponent.Attack(true, col.gameObject, gameObject);
        }
    }
Beispiel #5
0
        public void Update()
        {
            directionCount--;
            if (directionCount <= 0)
            {
                switch (RandomIntGenerator.Instance.Next(0, 4))
                {
                case 0:
                    enemy.North();
                    break;

                case 1:
                    enemy.East();
                    break;

                case 2:
                    enemy.South();
                    break;

                case 3:
                    enemy.West();
                    break;

                case 4:
                    enemy.Attack();
                    break;

                default:
                    // Do nothing, this is not supposed to happen
                    break;
                }
                directionCount = RandomIntGenerator.Instance.Next(MIN_DIRECTION_COUNTS, MAX_DIRECTION_COUNTS);
            }
        }
        private void Awake()
        {
            //Сброс
            _playerStatsTextRefs = new Dictionary <int, Text>();
            _enemyStatsTextRefs  = new Dictionary <int, Text>();
            _statsSpriteCache    = new Dictionary <int, Sprite>();
            _buffsSpriteCache    = new Dictionary <int, Sprite>();

            //Подписка кнопок старта
            _startBuffsButton.onClick.AddListener(() =>
            {
                _gameManager.StartGameWithBuffs();
            });

            _startDefaultButton.onClick.AddListener(() =>
            {
                _gameManager.StartGame();
            });

            //Подписка кнопок панелей
            _playerPanel.attackButton.onClick.AddListener(() =>
            {
                _player.Attack();
            });

            _enemyPanel.attackButton.onClick.AddListener(() =>
            {
                _enemy.Attack();
            });
        }
    public bool Act(IContext context)
    {
        IEnemy enemy = (IEnemy)context.GetVariable("IEnemy");

        enemy.Attack();
        return(true);
    }
Beispiel #8
0
 private void Update()
 {
     if (Input.GetMouseButtonDown(0))
     {
         enemy.Attack();
     }
 }
Beispiel #9
0
        static void Main(string[] args)
        {
            IEnemyFactory enemyFactory = LoadFactory();

            IEnemy enemy = enemyFactory.CreateEnemy();

            enemy.Attack();
            enemy.Die();
        }
Beispiel #10
0
        static void Main(string[] args)
        {
            string enemyName = args[0];


            IEnemy enemy = GetEnemy(enemyName);

            enemy.Attack();
            enemy.Die();
            Console.ReadLine();
        }
Beispiel #11
0
 public bool GetGamage(IEnemy a)
 {
     if (Health > 0)
     {
         Health -= a.Attack();
     }
     else if (Health <= 0)
     {
         IsLife = false;
     }
     return(IsLife);
 }
        public void playerEnemyHandler(Rectangle collisionRect, IPlayer player, IEnemy enemy, IRoom room, Sounds sound)
        {
            //get direction
            int direction;
            //0=up, 1=right, 2=down, 3= left
            int xCollisionSize = collisionRect.Width;
            int yCollisionSize = collisionRect.Height;

            // We are in a Top / Bottom style collision
            if (xCollisionSize > yCollisionSize)
            {
                // IF the bottom left corner of our enemy is less than the the top left corner of the block
                // AND the bottom left corner of our enemy is greater than the half way point of the height of the block
                // We are on the bottom
                if (collisionRect.Y == enemyRect.Y)
                {
                    direction = 2;
                }
                else // We are on the top
                {
                    direction = 0;
                }
            }
            else // We are in a Left / Right style collision
            {
                // IF the top left corner of our enemy is less than the top right corner of the block
                // AND the top left corner of our enemy is greater than the half way point of the width of the block
                // We are on the right
                if (collisionRect.X == enemyRect.X)
                {
                    direction = 1;
                }
                else // We are on the left
                {
                    direction = 3;
                }
            }

            if (player.IsAttacking() && direction == player.GetDirection())
            {
                player.dealDamage(enemy);
                if (enemy.getHealth() <= 0)
                {
                    sound.EnemyHitDie(1);
                    room.RemoveEnemy(enemy);
                }
            }
            else
            {
                enemy.Attack(player);
                //game over if health<=0. do this later once we have game over procedure.
            }
        }
Beispiel #13
0
        static void Main(string[] args)
        {
            string enemyName = args[0];

            EnemyFactory enemyFactory = new EnemyFactory();

            // now the main class 'program' isn't aware of
            // the enemy types anymore (good)
            // but its aware of the particular factory (bad)
            IEnemy enemy = enemyFactory.CreateInstance(enemyName.ToLower());

            enemy.Attack();
            enemy.Die();
        }
Beispiel #14
0
 private bool Attack(IPlayer player, IEnemy enemy, bool useMagic, int enemyAttackChance, bool enemyCanAttack)
 {
     if (player.GetCurrentStats().AttackSpeed >= enemy.GetCurrentStats().AttackSpeed)
     {
         player.Attack(useMagic, enemy);
         if (enemy.GetCurrentStats().CurrentHealth <= 0)
         {
             Victory();
             return(true);
         }
         if (enemyCanAttack)
         {
             enemy.Attack(enemyAttackChance % 2 == 0 && enemy.GetCurrentStats().CurrentMana >= enemy.GetCurrentStats().ManaCost, player);
             if (player.IsDefeated(enemy))
             {
                 Defeat();
                 return(true);
             }
         }
     }
     else
     {
         enemy.Attack(enemyAttackChance % 2 == 0 && enemy.GetCurrentStats().CurrentMana >= enemy.GetCurrentStats().ManaCost, player);
         if (player.IsDefeated(enemy))
         {
             Defeat();
             return(true);
         }
         player.Attack(useMagic, enemy);
         if (enemy.GetCurrentStats().CurrentHealth <= 0)
         {
             Victory();
             return(true);
         }
     }
     return(false);
 }
Beispiel #15
0
        static void Main(string[] args)
        {
            AbstractFactory normalEnemyFactory = AbstractFactory.GetFactory(EEnemyType.Normal);
            IEnemy          normalEnemy        = normalEnemyFactory.MakeEnemy();

            normalEnemy.Attack();
            normalEnemy.Heal();
            normalEnemy.Die();
            AbstractFactory bigEnemyFactory = AbstractFactory.GetFactory(EEnemyType.Big);
            IEnemy          bigEnemy        = bigEnemyFactory.MakeEnemy();

            bigEnemy.Attack();
            bigEnemy.Heal();
            bigEnemy.Die();
            Console.Read();
        }
Beispiel #16
0
        /// <summary>
        /// Army Defends against the Enemy
        /// </summary>
        /// <param name="enemy"></param>
        private void Defend(IEnemy enemy)
        {
            var liveSoldiers = Recruits.Where(r => !r.IsDead);

            DisplayDefendMessage();

            foreach (var soldier in liveSoldiers)
            {
                var attackDamage = enemy.Attack();
                _writer.WriteMessage(enemy.AttackMessage());
                soldier.Defend(enemy.AttackType, attackDamage);

                // Wonder about putting this inside Defend, but then defend would need to return a string which might be weird?
                _writer.WriteMessage(soldier.DefendMessage(enemy.AttackType, attackDamage));
            }
        }
Beispiel #17
0
        public void Update()
        {
            directionCount--;
            if (directionCount <= 0)
            {
                if (enemy.Velocity.Direction == Vector.Orientation.East)
                {
                    enemy.West();
                }
                else
                {
                    enemy.East();
                }

                directionCount = MAX_DIRECTION_COUNTS;
            }

            attackCount--;
            if (attackCount <= 0)
            {
                enemy.Attack();
                attackCount = RandomIntGenerator.Instance.Next(MIN_ATTACK_COUNTS, MAX_ATTACK_COUNTS);
            }
        }
Beispiel #18
0
 public void Attack()
 {
     enemy.Attack(temp_target, shootStart);
     temp_target = null;
 }
Beispiel #19
0
 private void Attack()
 {
     StartCoroutine(enemyComponent.Attack(this, target));
     isAttacking = true;
 }
Beispiel #20
0
        private void EnemyAttacks()
        {
            int damage = _enemy.Attack(_player);

            _player.Hit(damage);
        }
 public void Act()
 {
     enemy.Attack();
     enemy.Move();
 }