Esempio n. 1
0
    /// <summary>
    /// Method is called at the end of each turn.
    /// </summary>
    public virtual void OnTurnEnd()
    {
        Buffs.FindAll(b => b.Duration == 0).ForEach(b => { b.Undo(this); });
        Buffs.RemoveAll(b => b.Duration == 0);
        Buffs.ForEach(b => { b.Duration--; });

        SetState(new UnitStateNormal(this));
    }
Esempio n. 2
0
    //MoveShip ();


    //TODO 100
    //int number = cellgrid.GetComponents<RectangularHexGridGenerator>
    /// <summary>
    /// Method is called at the end of each turn.
    /// </summary>
    public override void OnTurnEnd()
    {
        Debug.Log("Space SpaceMover OnTurnEnd called");
        Buffs.FindAll(b => b.Duration == 0).ForEach(b => { b.Undo(this); });
        Buffs.RemoveAll(b => b.Duration == 0);
        Buffs.ForEach(b => { b.Duration--; });

        SetState(new UnitStateNormal(this));
    }
Esempio n. 3
0
    /// <summary>
    /// Method is called at the end of each turn.
    /// </summary>
    public virtual void OnTurnEnd()
    {
        Buffs.FindAll(b => b.Duration == 0).ForEach(b => { b.Undo(this); });
        Buffs.RemoveAll(b => b.Duration == 0);
        Buffs.ForEach(b => { b.Duration--; });
        Animator anim = GetComponentInChildren <Animator>();

        SetState(new UnitStateNormal(this));
    }
Esempio n. 4
0
    /// <summary>
    /// Method is called at the end of each turn.
    /// </summary>
    public virtual void OnTurnEnd()
    {
        Buffs.FindAll(b => b.Duration == 0).ForEach(b => { b.Undo(this); });
        Buffs.RemoveAll(b => b.Duration == 0);
        Buffs.ForEach(b => { b.Duration--; });

        //handlecapture in this method
        if (canCapture && isAbleToCapture)
        {
        }

        ResetToNeutralState();
        prevPosition = this.transform.position;
        prevCell     = Cell;
        SetState(new UnitStateNormal(this));
    }
Esempio n. 5
0
        public override void Draw()
        {
            if (IsAlive)
            {
                Buffs.ForEach(b => b.Draw());
            }
            var angle = -(float)Math.Atan2(Facing.Y, Facing.X) + SpriteRotation();
            var rect  = GetCurrentAnimation().CurrentRectangle;
            var scale = Width / rect.Width;

            this.DrawGameObject(
                sourceRectangle: rect,
                color: Color.White * Opacity,
                scale: new Vector2(scale),
                rotation: angle,
                origin: GetCurrentAnimation().CurrentOrigin);
            if (Globals.ShowHitboxes && IsAlive)
            {
                Hitbox().ForEach(r => Globals.WhiteTexture.Draw(r, Color.Green));
            }
        }
Esempio n. 6
0
    /// <summary>
    /// Method is called at the end of each turn.
    /// </summary>
    public virtual void OnTurnEnd()
    {
        Buffs.FindAll(b => b.Duration == 0).ForEach(b => { b.Undo(this); });
        Buffs.RemoveAll(b => b.Duration == 0);
        Buffs.ForEach(b => { b.Duration--; });

        SetState(new UnitStateNormal(this));
        isTurnEnd = true;

        if (this.tag == "Player")
        {
            int nextIndex = this.GetComponent <Avatar>().AvatarIndex + 1;
            if (nextIndex > 3)
            {
                nextIndex = 0;
            }
            moveToNextAvatar(nextIndex);
        }

        //Debug.Log("Player Number: "+PlayerNumber);
        //selectUnitBtn();
    }
Esempio n. 7
0
        public override void Draw()
        {
            if (IsAlive)
            {
                Buffs.ForEach(b => b.Draw());
            }
            var angle     = -(float)Math.Atan2(Facing.Y, Facing.X) + SpriteRotation();
            var animation = ZerdAnimations.Animations[GetCurrentAnimationType()];

            if (animation.Keys.Contains(BodyPartType.Feet))
            {
                FeetTexture.Draw(sourceRectangle: animation[BodyPartType.Feet].CurrentRectangle,
                                 color: Color.White, position: new Vector2(X, Y), rotation: angle, origin:
                                 new Vector2(ZerdAnimationHelpers.Feet.Width / 2, ZerdAnimationHelpers.Feet.Height / 2), scale: BodyScaleVector);
            }
            if (animation.Keys.Contains(BodyPartType.Hands))
            {
                HandTexture.Draw(sourceRectangle: animation[BodyPartType.Hands].CurrentRectangle,
                                 color: Color.White, position: new Vector2(X, Y), rotation: angle, origin:
                                 new Vector2(ZerdAnimationHelpers.Hands.Width / 2, ZerdAnimationHelpers.Hands.Height / 2), scale: BodyScaleVector);
            }
            if (animation.Keys.Contains(BodyPartType.Chest))
            {
                ChestTexture.Draw(sourceRectangle: animation[BodyPartType.Chest].CurrentRectangle,
                                  color: Color.White, position: new Vector2(X, Y), rotation: angle, origin:
                                  new Vector2(ZerdAnimationHelpers.Chest.Width / 2, ZerdAnimationHelpers.Chest.Height / 2), scale: BodyScaleVector);
            }
            if (animation.Keys.Contains(BodyPartType.Head))
            {
                HeadTexture.Draw(sourceRectangle: animation[BodyPartType.Head].CurrentRectangle,
                                 color: Color.White, position: new Vector2(X, Y), rotation: angle, origin:
                                 new Vector2(ZerdAnimationHelpers.Head.Width / 2, ZerdAnimationHelpers.Head.Height / 2), scale: BodyScaleVector);
            }
            if (Globals.ShowHitboxes && IsAlive)
            {
                Hitbox().ForEach(r => Globals.WhiteTexture.Draw(r, Color.Green));
            }
        }
Esempio n. 8
0
        public override void Update(GameTime gameTime)
        {
            var origX = X;
            var origY = Y;

            if (!IsAlive)
            {
                Velocity  = Vector2.Zero;
                Speed     = 0;
                Knockback = null;
            }
            else
            {
                Speed = BaseSpeed;

                if (this is Zerd)
                {
                    Speed *= this.SkillValue(SkillType.Swiftness, true);
                }

                Buffs.ForEach(b =>
                {
                    Speed     += b.MovementSpeedFactor;
                    var damage = b.DamagePerSecond * (float)gameTime.ElapsedGameTime.TotalSeconds * Globals.GameState.GameSpeed;
                    if (damage > 0)
                    {
                        new DamageInstance(null, damage, b.DamageType, b.Applier, b.AbilityType, false).DamageBeing(this);
                    }
                    b.TimeRemaining = b.TimeRemaining.SubtractWithGameSpeed(gameTime.ElapsedGameTime);
                    if (b is DashBuff && this is Zerd && ((Zerd)this).SkillPoints(SkillType.ColdWinds) > 0)
                    {
                        foreach (var e in this.Enemies().Where(e => e.Buffs.All(b2 => !(b2 is FrozenBuff)) && e.Hitbox().Any(h => Hitbox().Any(h.Intersects))))
                        {
                            e.AddBuff(new FrozenBuff(e, TimeSpan.FromSeconds(((Zerd)this).SkillValue(SkillType.ColdWinds, false))));
                        }
                    }
                });

                if (Buffs.Any(b => b is SprintBuff) && this is Zerd)
                {
                    Speed *= 1 + ((Zerd)this).Player.AbilityUpgrades[AbilityUpgradeType.SprintSpeed] / 100;
                }
                else if (this is Zerd)
                {
                    Speed *= 1 + ((Zerd)this).Player.AbilityUpgrades[AbilityUpgradeType.MovementSpeed] / 100;
                }

                Speed = MathHelper.Clamp(Speed, GameplayConstants.MinSpeed, GameplayConstants.MaxSpeed);

                Buffs.ForEach(b => Speed = b.Frozen ? 0 : Speed);

                Buffs = Buffs.Where(b => b.TimeRemaining > TimeSpan.Zero).ToList();

                Health += HealthRegen * (float)gameTime.ElapsedGameTime.TotalSeconds * Globals.GameState.GameSpeed;
                if (this is Zerd)
                {
                    Health += HealthRegen * (float)gameTime.ElapsedGameTime.TotalSeconds * Globals.GameState.GameSpeed *
                              ((Zerd)this).Player.AbilityUpgrades[AbilityUpgradeType.HealthRegen] / 100;
                }
                Mana += ManaRegen * (float)gameTime.ElapsedGameTime.TotalSeconds * Globals.GameState.GameSpeed;
                if (this is Zerd)
                {
                    Mana += ManaRegen * (float)gameTime.ElapsedGameTime.TotalSeconds * Globals.GameState.GameSpeed *
                            ((Zerd)this).Player.AbilityUpgrades[AbilityUpgradeType.ManaRegen] / 100;
                }

                if (Knockback == null)
                {
                    var angle = Velocity.AngleBetween(Facing);
                    Speed *= angle < GameplayConstants.ZerdFrontFacingAngle ? 1 : angle > 180 - GameplayConstants.ZerdFrontFacingAngle ? GameplayConstants.BackpedalFactor : GameplayConstants.SideStepFactor;
                    if (Velocity.Length() > 0.01)
                    {
                        X += Velocity.X * Speed * (float)gameTime.ElapsedGameTime.TotalSeconds * Globals.GameState.GameSpeed;
                        Y -= Velocity.Y * Speed * (float)gameTime.ElapsedGameTime.TotalSeconds * Globals.GameState.GameSpeed;
                    }
                }
                else
                {
                    if (Knockback.Speed > 0 && Knockback.MaxDuration > TimeSpan.Zero)
                    {
                        X += (int)(Knockback.Direction.X * Knockback.Speed * gameTime.ElapsedGameTime.TotalSeconds *
                                   (float)Math.Pow(Knockback.Duration.TotalMilliseconds / Knockback.MaxDuration.TotalMilliseconds, GameplayConstants.KnockbackDecay)) *
                             Globals.GameState.GameSpeed;
                        Y += (int)(Knockback.Direction.Y * Knockback.Speed * gameTime.ElapsedGameTime.TotalSeconds *
                                   (float)Math.Pow(Knockback.Duration.TotalMilliseconds / Knockback.MaxDuration.TotalMilliseconds, GameplayConstants.KnockbackDecay)) *
                             Globals.GameState.GameSpeed;
                    }
                    Knockback.Duration = Knockback.Duration.SubtractWithGameSpeed(gameTime.ElapsedGameTime);
                    if (Knockback.Duration < TimeSpan.Zero)
                    {
                        Knockback = null;
                    }
                }

                Health = MathHelper.Clamp(Health, 0, MaxHealth);
                Mana   = MathHelper.Clamp(Mana, 0, MaxMana);
            }

            // If we tried to move make sure we aren't hitting anything, else reject the move (only reject one dimension if needed)
            if (X != origX || Y != origY)
            {
                if (Globals.Map.CollidesWithWall(this))
                {
                    var newX = X;
                    var newY = Y;
                    X = origX;
                    // Try just moving the Y
                    if (Globals.Map.CollidesWithWall(this))
                    {
                        X = newX;
                        Y = origY;
                        // Try just moving the X
                        if (Globals.Map.CollidesWithWall(this))
                        {
                            // Can't move either axis
                            X = origX;
                        }
                    }
                }
            }

            GetCurrentAnimation().Update(gameTime);
            Buffs.ForEach(b => b.Update(gameTime));
        }