protected bool[] drawFlagArray;     //indicates whether to draw each individual sprite;

        /// <summary>
        /// 
        /// </summary>
        /// <param name="ProjectilePath">Points to move through in the grid</param>
        /// <param name="EffectList">Effects to take on each target hit.</param>
        /// <param name="ProjectileAnimations">The animations that will play as this projectile flies.</param>
        /// <param name="ImpactSprite">Sprite while plays once when the projectile hits a target.</param>
        /// <param name="Caster">Originator of the projectile.</param>
        /// <param name="targetEnemies">Chooses whether this projectile will hit enemies</param>
        /// <param name="targetFriendlies">Chooses whether this projectile will hit people on the same team</param>
        /// <param name="DamageFalloff">Ratio by which to reduce each effect each time a target is hit. (multiplies by 1-damageFalloff)</param>
        /// <param name="DurationFalloff">Ratio by which to reduce each effect duration each time a target is hit. (multiplies by 1-durationFalloff</param>
        public SpaceProjectile(List<Vector2> ProjectilePath, AbilityEffect[] EffectList, Sprite[] ProjectileAnimations,
                               Sprite ImpactSprite, Person Caster = null, bool targetEnemies = true, bool targetFriendlies = false, 
                               float DamageFalloff = 0, float DurationFalloff = 0)
            : base(EffectList, ProjectileAnimations, ImpactSprite, Caster, targetEnemies, targetFriendlies, DamageFalloff, DurationFalloff)
        {
            Path = ProjectilePath;
        }
 /// <summary>
 /// Puts the Projectile's effects on the target, then reduces values as necesasary.
 /// </summary>
 /// <param name="target">Person hit by the projectile.</param>
 public void CauseEffect(Person target)
 {
     foreach (AbilityEffect effect in effects)
     {
         target.takeEffect(effect);
         effect.multiplyDurations(1 - durationFalloff);
         effect.multiplyEffects(1 - damageFalloff);
     }
     targetsHit.Add(target);
 }
 private Person caster;              //Person from whom this effect originated.
 
 /// <summary>
 /// AbilityEffect main constructor for all values
 /// </summary>
 /// <param name="damage">Damage done immediately on hit.</param>
 /// <param name="damageATurn">Damage done per turn to all hit.</param>
 /// <param name="dotLength">Duration of the DoT effect, if there is one</param>
 /// <param name="energyHit">Energy removed from the target immediately on hit.</param>
 /// <param name="energyDoT">Energy removed per turn on all hit.</param>
 /// <param name="EoTLength">Duration of the EoT</param>
 /// <param name="Caster">Originator of this Effect.</param>
 /// <param name="iconSprite">Icon for the debuff to display in the character stat sheet.</param>
 /// <param name="overlaySprite">Sprite which draws over the character on the grid while this effect is on.</param>
 public AbilityEffect(float damage, float damageATurn, float dotLength, float energyHit, float energyDoT, float EoTLength, Sprite iconSprite, Sprite overlaySprite = null, Person Caster = null)
 {
     damageOnHit = damage;
     damagePerTurn = damageATurn;
     dotDuration = dotLength;
     energyDamage = energyHit;
     energyDamagePerTurn = energyDoT;
     eotDuration = EoTLength;
     debuffSprite = iconSprite;
     caster = Caster;
     effectSprite = overlaySprite;
 }
        protected bool deleteFlag = false;             //Indicates to the owning space whether this projectile is ready to be deleted.
#endregion
        
#region Setup
        /// <summary>
        /// Constructs a projectile to carry Ability Effects across the screen.
        /// </summary>
        /// <param name="EffectList">Effects to take on each target hit.</param>
        /// <param name="ProjectileAnimations">The animations that will play as this projectile flies.</param>
        /// <param name="ImpactSprite">Sprite while plays once when the projectile hits a target.</param>
        /// <param name="Caster">Originator of the projectile.</param>
        /// <param name="DamageFalloff">Ratio by which to reduce each effect each time a target is hit. (multiplies by 1-damageFalloff)</param>
        /// <param name="DurationFalloff">Ratio by which to reduce each effect duration each time a target is hit. (multiplies by 1-durationFalloff)</param>
        /// <param name="targetEnemies">Chooses whether this projectile will hit enemies.</param>
        /// <param name="targetFriendlies">Chooses whether this projectile will hit people on the same team</param>
        public Projectile(AbilityEffect[] EffectList, Sprite[] ProjectileAnimations, Sprite ImpactSprite, Person Caster = null, bool targetEnemies = true, bool targetFriendlies = false, float DamageFalloff = 0, float DurationFalloff = 0)
        {
            effects = EffectList;
            projectileAnimations = ProjectileAnimations;
            impactSprite = ImpactSprite;
            caster = Caster;
            damageFalloff = DamageFalloff;
            durationFalloff = DurationFalloff;
            targetsHit = new List<Person>();
            hitEnemies = targetEnemies;
            hitFriendlies = targetFriendlies;
        }
        protected float distanceToTravel, distanceTravelled;    //Trackers for the delete flag, so that we can delete once it's hit its target.
#endregion


#region Setup
        /// <summary>
        /// Creates a projectile which moves in a straight line from caster to target
        /// </summary>
        /// <param name="target">Person at which the projectile is aimed.</param>
        /// <param name="Speed">Speed at which the projectile moves per frame</param>
        /// <param name="EffectList">All the effects to put on targets</param>
        /// <param name="ProjectileAnimations">The animations that will play as this projectile flies.</param>
        /// <param name="ImpactSprite">Sprite while plays once when the projectile hits a target.</param>
        /// <param name="Caster">Originator of the projectile.</param>
        /// <param name="DamageFalloff">Ratio by which to reduce each effect each time a target is hit. (multiplies by 1-damageFalloff)</param>
        /// <param name="DurationFalloff">Ratio by which to reduce each effect duration each time a target is hit. (multiplies by 1-durationFalloff</param>
        /// <param name="targetEnemies">Chooses whether this projectile will hit enemies</param>
        /// <param name="targetFriendlies">Chooses whether this projectile will hit people on the same team</param>
        /// <param name="CasterToProjectileAnim">Sprite that displays between the caster and the projectile.</param>
        /// <param name="CasterToTargetAnim">Sprite that displays between the caster and the target</param>
        /// <param name="ProjectileToTargetAnim">Sprite that displays between the projectile and the target</param>
        public StraightProjectile(Person target, float Speed, AbilityEffect[] EffectList, Sprite[] ProjectileAnimations, Sprite ImpactSprite = null, Person Caster = null,
                                  bool targetEnemies = true, bool targetFriendlies = false, float DamageFalloff = 0, float DurationFalloff = 0, 
            Sprite CasterToProjectileAnim = null, Sprite CasterToTargetAnim = null, Sprite ProjectileToTargetAnim = null)
            : base(EffectList, ProjectileAnimations, ImpactSprite, Caster, targetEnemies, targetFriendlies, DamageFalloff, DurationFalloff)
        {
            originLoc = Caster.ScreenPositionNoOffset;
            currentLoc = Caster.ScreenPositionNoOffset;
            targetLoc = target.ScreenPositionNoOffset;
            animCasterToProj = CasterToProjectileAnim;
            animCasterToTarget = CasterToTargetAnim;
            animProjToTarget = ProjectileToTargetAnim;
            speed = Speed;
            distanceTravelled = 0;
            distanceToTravel = Vector2.Distance(originLoc, targetLoc);
        }
Example #6
0
        public void onClick(Vector2 screenPosition)
        {
            GridSpace tempGS = spaceAtScreenpos(Controls.MousePosition);
            Person temp = (Person)tempGS.CurrentActor;

            switch (gridState)
            {
                case GridState.noSelection:
                    if (temp != null)
                    {
                        selectedPerson = temp;
                        foreach (GridSpace space in spaceArray)
                        {
                            space.AvailableFlag = false;
                        }
                        availableSpaces = getAvailableMoveSpaces(selectedPerson.BaseMoveSpeed, tempGS.GridPosition, true, false);
                        foreach (Vector2 v in availableSpaces)
                        {
                            spaceArray[(int)v.X, (int)v.Y].AvailableFlag = true;
                        }
                        changeState(GridState.selectedMotionAvailable);
                    }
                    break;

                case GridState.castAnimating:
                    break;

                case GridState.selectedCastAvailable:
                    break;

                case GridState.selectedMotionAvailable:
                    foreach (GridSpace space in spaceArray)
                    {
                        space.AvailableFlag = false;
                    }
                    currentPath = Dijkstra(selectedPerson.GridPosition, tempGS.GridPosition, true, false);
                    int movesDone = 0;
                    if (currentPath.Count > 0)
                    {
                        LinkedListNode<Vector2> current = currentPath.First;
                        while (movesDone < selectedPerson.BaseMoveSpeed && current.Next != null)
                        {
                            movesDone += movementCosts[(int)current.Value.X, (int)current.Value.Y, (int)current.Next.Value.X, (int)current.Next.Value.Y];
                            current = current.Next;
                        }
                        while (current.Next != null)
                        {
                            currentPath.Remove(current.Next);
                        }
                        animationFinalGoal = spaceArray[(int)currentPath.Last.Value.X, (int)currentPath.Last.Value.Y];
                        animationCurrentGoal = currentPath.First.Value;
                        animatingActorScreenPos = selectedPerson.ScreenPosition;
                        currentPath.RemoveFirst();
                        if ((int)animationCurrentGoal.X % 2 == 1)
                        {
                            animationCurrentGoal.Y += 0.5f;
                        }
                        animationCurrentGoal.X *= 3 * ConstantHolder.HexagonGrid_HexSizeX / 4;
                        animationCurrentGoal.Y *= ConstantHolder.HexagonGrid_HexSizeY;
                        animationCurrentGoal -= originScreenPos;
                        animationCurrentGoal += new Vector2(ConstantHolder.HexagonGrid_HexSizeX / 3, ConstantHolder.HexagonGrid_HexSizeY);
                        animatingActor = selectedPerson;
                        spaceArray[(int)selectedPerson.GridPosition.X, (int)selectedPerson.GridPosition.Y].removeActor();
                        selectedPerson = null;
                        changeState(GridState.selectedMoving);
                    }
                    break;

                case GridState.selectedMoving:
                    break;
            }
        }
Example #7
0
        /// <summary>
        /// Starts a timer on the Caster based on the Ability's ChannelTime, and at the end of the timer, launches the ability and its effects at the target. 
        /// </summary>
        /// <param name="Caster">Originator of the ability, who spends the mana, takes any lashback damage, and takes the credit.</param>
        /// <param name="Target">Person towards which the </param>
        public bool StartCast(Person Caster, Person Target)
        {
            if (!Caster.CanAct || Caster.Energy < energyCost || Caster.Health < lashbackDamage) return false;   //Checks any conditions that would make the Caster unable to use this ability.
            caster = Caster;
            target = Target;
            caster.CanAct = false;
            currentCD = cooldown;

            return true;
        }
Example #8
0
 /// <summary>
 /// Starts the dying animation playing, and once those are done, removes the player from the grid.
 /// </summary>
 /// <param name="killer"></param>
 public void Die(Person killer)
 {
     //TBI: Move all sprites into the temporary set, empty the main set. Set all temp columns to Dying column, where available.
     //After all sprites have finished, delete.
     //NOTE: In Hero override, they should only be set to the Dying column, not moved to temporary. After they go through dying, they should go to the Dead column.
 }
Example #9
0
 /// <summary>
 /// Deals health and energy damage to the person, who dies if their health reaches 0.
 /// </summary>
 /// <param name="Caster">Person to be given credit if this person dies.</param>
 /// <param name="healthDamage">Amount of health to lose. Negative amounts will heal, up to the person's max health.</param>
 /// <param name="energyDamage">Amount of energy to lose. Negative amounts will restore, up to the person's max energy.</param>
 public void takeDamage(Person Caster, float healthDamage, float energyDamage)
 {
     internalEnergy = Math.Min(maxEnergy, Math.Max(0, internalEnergy - energyDamage));
     visibleEnergy = (int) internalEnergy;
     internalHealth = Math.Min(maxHealth, Math.Max(0, internalHealth - healthDamage));
     visibleHealth = (int)internalHealth;
     if (internalHealth <= 0)
     {
         Die(Caster);
     }
 }
        public static void startCast(Person caster, int abilityIndex)
        {

        }
 /// <summary>
 /// Update the statBox to use the specified person as the displayed top character
 /// </summary>
 /// <param name="newPerson">The new person</param>
 public void setSelected(Person newPerson)
 {
     if (newPerson != null)
     {
         selectedChar = newPerson;
         //Options[0].ChangeText(newPerson.Abilities[0].ToString());
     }
 }
 /// <summary>
 /// Draws the tooltip when mousing over a character
 /// </summary>
 /// <param name="batch">Main drawing batch</param>
 /// <param name="target">Character being moused over</param>
 /// <param name="position">Top left of the drawing position.</param>
 public void drawMouseOverStats(SpriteBatch batch, Person target, Vector2 position)
 {
     float healthpct = (float)(target.Health) / (float)target.MaximumHealth;
     float energypct = (float)(target.Energy) / (float)target.MaxEnergy;
     Rectangle drawingLoc = new Rectangle((int)position.X, (int)position.Y, 70, 35);
     mouseoverBackground.Draw(batch, drawingLoc);
     mouseOverFrame.Draw(batch, drawingLoc);
     drawingLoc.X += 5;
     drawingLoc.Y += 5;
     drawingLoc.Width -= 10;
     drawingLoc.Height = 10;
     healthBarM.Draw(batch, drawingLoc, Color.Blue);
     healthBarM.Draw(batch, drawingLoc, new Vector2(healthpct, 1.0f));
     drawingLoc.Y += 15;
     energyBarM.Draw(batch, drawingLoc, Color.Purple);
     energyBarM.Draw(batch, drawingLoc, new Vector2(energypct, 1.0f));
 }
        /// <summary>
        /// Handles the details of drawing the necessary stats as well as pictures and backgrounds.
        /// </summary>
        /// <param name="spriteBatch">Main drawing batch</param>
        /// <param name="person">Character whose stats are being drawn.</param>
        /// <param name="position">Top left corner of the box</param>
        public void drawStats(SpriteBatch spriteBatch, Person person)
        {
            SpriteFont Font = InterfaceTextureHolder.Holder.Fonts[(int)ConstantHolder.Fonts.defaultFont];
            float textLineHeight = Font.MeasureString("QWERTYUIOPASDFGHJKLZXCVBNMqwertyuiopasdfghjklzxcvbnm,./?><';:\"[]\\|}{!@#$%^&*()_+1234567890-=`~").Y;
            float healthpct = (float)(person.Health) / (float)person.MaximumHealth;
            float energypct = (float)(person.Energy) / (float)person.MaxEnergy;
            int expToNextLevel = person is Hero ? ((Hero)person).ExperienceToLevel : 0;
            float exppct = person is Hero ? ((Hero)person).CurrentExperience * 1.0f/ expToNextLevel : 0;

            //Picture and name/level
            Rectangle loc = new Rectangle(HealthBox.X + 5, HealthBox.Y + 5, HealthBox.Width - 10, HealthBox.Width - 10);
            person.Portrait.Draw(spriteBatch, loc);
            loc.Y += HealthBox.Width;
            loc.Height = 15;
            healthBar.Draw(spriteBatch, loc, Color.Blue);
            healthBar.Draw(spriteBatch, loc, new Vector2(healthpct, 1.0f));
            loc.Y += 25;
            energyBar.Draw(spriteBatch, loc, Color.Purple);
            energyBar.Draw(spriteBatch, loc, new Vector2(energypct, 1.0f));
            if(person is Hero)
            {
                Hero tempChar = (Hero)person;
                spriteBatch.DrawString(Font, tempChar.Name + "\nLevel " + tempChar.Level, new Vector2(loc.X + 15, loc.Y + 15), Color.Black, 0.0f, new Vector2(0, 0), 1.0f, SpriteEffects.None, 0);
                loc.X = ExpBarBox.X;
                loc.Y = ConstantHolder.GAME_HEIGHT - 20;
                loc.Width = ExpBarBox.Width;
                loc.Height = 20;
                experienceBar.Draw(spriteBatch, loc, Color.Black);
                experienceBar.Draw(spriteBatch, loc, new Vector2(exppct, 1.0f));
            }
            for (int i = 0; i < 4; ++i)
            {
                Options[i].Draw(spriteBatch);
            }
            loc.X = 0;
            loc.Y = ConstantHolder.GAME_HEIGHT - 20;
            loc.Width = 20;
            loc.Height = 20;
            for (int i = 0; i < Math.Min(ExpBarBox.X / 20, person.EffectsOnPerson.Count); ++i)
            {
                person.EffectsOnPerson[i].DebuffIcon.Draw(spriteBatch, loc);
                loc.X += 20;
            }
        }
 /// <summary>
 /// Checks for a moused-over or newly selected person.
 /// </summary>
 public void update()
 {
     MouseOverChar = MainframeGame.currentLevelGrid.personAtScreenPos(Controls.MousePosition);
     if (Controls.ButtonsLastDown[(int)Controls.ButtonNames.leftMouse] && !Controls.ButtonsDown[(int)Controls.ButtonNames.leftMouse])
     {
         setSelected(MouseOverChar);
     }
     foreach (Button b in Options)
     {
         b.Update();
     }
 }
 /// <summary>
 /// Update the statBox to use the specified character as the displayed bottom character
 /// </summary>
 /// <param name="newCharacter">The new character</param>
 public void SetMouseOver(Person newCharacter)
 {
     MouseOverChar = newCharacter;
 }