コード例 #1
0
ファイル: Tower.cs プロジェクト: RamiAhmed/Tower-Shake
        private Critter shoot(Tower tower, Critter critter)
        {
            if (Sprite.GetIsInRange(tower.Position, critter.Position, tower.Range))
            {
                if (tower.AttackState == AttackState.Shooting)
                {
                    float bulletSpeed = 5.0f + (float)RandomHandler.GetRandom(0.0, 2.0);
                    bool hitCritter = false;
                    if (tower.Accuracy + RandomHandler.GetRandom() >= critter.Dexterity + RandomHandler.GetRandom())
                    {
                        hitCritter = true;
                    }

                    tower.AttackState = AttackState.Reloading;
                    tower.LastAttack = getCurrentMilliseconds();
                    createBullet(bulletSpeed, tower, critter, hitCritter);
                }
                else
                {
                    if (getCurrentMilliseconds() - tower.LastAttack > (long)(tower.ReloadSpeed * 1000))
                    {
                        Console.WriteLine(tower.ToString() + " finished reloading");
                        tower.AttackState = AttackState.Shooting;
                    }
                }
            }
            return critter;
        }
コード例 #2
0
ファイル: Tower.cs プロジェクト: RamiAhmed/Tower-Shake
 private void init()
 {
     critterClass = new Critter();
 }
コード例 #3
0
        private void init()
        {
            mouse = new Logic.Mouse();
            keyboard = new KeyboardHandler();

            player = new Player(this);
            critter = new Critter(this);
            tower = new Tower(this);

            RandomHandler.Init();
        }
コード例 #4
0
ファイル: Tower.cs プロジェクト: RamiAhmed/Tower-Shake
        private Bullet createBullet(float speed, Tower tower, Critter critter, Boolean hit)
        {
            Bullet bullet = new Bullet();
            bullet.Speed = speed;

            bullet.Position = new Vector2(tower.Position.X + (tower.Width / 2),
                                          tower.Position.Y + (tower.Height / 2));

            bullet.Direction = critter.Position - tower.Position;
            bullet.Direction.Normalize();

            Texture2D texture = null;
            switch (tower.Type)
            {
                case TowerType.RangedTower: texture = Presentation.PresentationController.BulletTexture2D;
                                            bullet.BulletColor = Color.DarkGray;
                                            break;
                case TowerType.MeleeTower: texture = Presentation.PresentationController.BulletTexture2D;
                                           bullet.BulletColor = Color.DarkRed;
                                           break;
                case TowerType.SlowTower: texture = Presentation.PresentationController.BulletTexture2D;
                                          bullet.Slow = true;
                                          bullet.BulletColor = Color.Cyan;
                                          break;
            }
            bullet.Texture = texture;

            bullet.Target = critter;
            bullet.Damage = tower.Damage;
            bullet.Hit = hit;

            bullet.Done = false;
            bullets.Add(bullet);
            return bullet;
        }
コード例 #5
0
ファイル: Bullet.cs プロジェクト: RamiAhmed/Tower-Shake
        private void slow(Critter critter)
        {
            float slowDamage = Constants.SlowTowerSlowAmount;

            if (critter.SlowDamage < slowDamage)
            {
                critter.SlowDamage = slowDamage;
            }
            critter.Slowed = LogicController.getCurrentSeconds();
        }