Beispiel #1
0
        public override void Draw(GameTime gameTime)
        {
            Camera.Draw(spriteBatch);
            Cursor.Instance.Draw(gameTime, spriteBatch);

            if (!Parameter.ShouldChangeBGScale)
            {
                Background.Draw(gameTime, spriteBatch);
            }

            PopupHandler.Draw(gameTime, spriteBatch);

            if (!Parameter.ShouldChangeBGScale)
            {
                BackgroundFlipbookList.ForEach((x) => x.Draw(gameTime, spriteBatch));
            }

            Foreground.Draw(gameTime, spriteBatch);

            WeatherHandler.Draw(gameTime, spriteBatch);

            lock (MobileList)
            {
                MobileList.ForEach((x) => x.Draw(gameTime, spriteBatch));
                HUD.Draw(gameTime, spriteBatch);
            }

            MineList.ForEach((x) => x.Draw(gameTime, spriteBatch));

            ThorSatellite.Draw(gameTime, spriteBatch);

            DeathAnimation.Draw(gameTime, spriteBatch);
            SpecialEffectHandler.Draw(gameTime, spriteBatch);
            TextBalloonHandler.Draw(spriteBatch);
        }
    //collision detections
    public void OnTriggerEnter2D(Collider2D other)
    {
        Debug.Log("hit");
        DeathAnimation sn = other.GetComponent <DeathAnimation>();

        sn.DeathEffect();
        FadeToLevel(1);
    }
Beispiel #3
0
        public void Attack(Point attackingUnit, Point defendingUnit)
        {
            Unit att = GetUnit(attackingUnit);
            Unit def = GetUnit(defendingUnit);

            ushort baseAtt = att.Stats[Stats.Attack];
            bool   isMagic = false;

            if (att.Stats[Stats.Magic] > baseAtt)
            {
                isMagic = true;
                baseAtt = att.Stats[Stats.Magic];
            }
            int diceResult = rand.Next(1, 7);

            RollDiceAnimation rollDiceAnimation = new RollDiceAnimation(game.RedDice, CellToWorld(att.Position).Add(0, Global.SpriteHeight), (ushort)diceResult, baseAtt, true);

            animationQueue.Add(rollDiceAnimation, null);

            int damage = baseAtt + diceResult;

            ushort baseDef = def.Defending ? (ushort)7 : (isMagic ? def.Stats[Stats.MagicDefense] : def.Stats[Stats.Defense]);

            diceResult = rand.Next(1, 7);

            rollDiceAnimation = new RollDiceAnimation(game.BlueDice, CellToWorld(def.Position).Add(0, Global.SpriteHeight), (ushort)diceResult, baseDef, true);
            animationQueue.Add(rollDiceAnimation, null);

            int defense = baseDef + diceResult;


            int res = Math.Max(0, damage - defense);

            animationQueue.Add(new AttackAnimation((ushort)res), null);

            if (def.Health <= res)
            {
                Sprite skull = new Sprite(game.Textures[3], Global.SpriteSize, TextureIDInterpreter.GetSourceRectangle(567), Global.Colors.Main1);

                DeathAnimation deathAnimation = new DeathAnimation(CellToWorld(def.Position).Add(1), def.GetSprite(game.Textures), CellToWorld(def.Position.Sub(0, 1)), skull);
                animationQueue.Add(deathAnimation, def);
                units[def.Position.Y, def.Position.X] = null;
            }
            else
            {
                def.Health -= (ushort)res;
            }

            att.Acted = true;

            UnselectUnit();
            UnselectTiles();
        }
        public static BaseObject GetDeathAnimationObject(DeathAnimation deathAnimation, Vector2 position)
        {
            var baseObject = new BaseObject {Id = "deathAnimation"};
            switch (deathAnimation)
            {
                    case DeathAnimation.Explosion:
                    baseObject.AddComponent(new Sprite(ManagerContent.LoadTexture("death_effect"), 16, 16, position));
                    baseObject.AddComponent(new Animation(16, 16, 3,100));
                    baseObject.AddComponent(new DeathAnimationExplosion());
                    baseObject.AddComponent(new Camera(_camera));
                    break;
            }

            return baseObject;
        }
Beispiel #5
0
        public virtual void Die()
        {
            if (!IsAlive)
            {
                return;
            }

            if (Rider != null)
            {
                Rider.Hide();
            }

            LevelScene.HUD.MobileDeath(this);
            DeathAnimation.Add(this);
            ChangeFlipbookState(ActorFlipbookState.Dead, true);
            IsAlive = false;
            OnDeath?.Invoke();
        }
        public static BaseObject GetDeathAnimationObject(DeathAnimation deathAnimation, Vector2 position)
        {
            var baseObject = new BaseObject {
                Id = "deathAnimation"
            };

            switch (deathAnimation)
            {
            case DeathAnimation.Explosion:
                baseObject.AddComponent(new Sprite(ManagerContent.LoadTexture("death_effect"), 16, 16, position));
                baseObject.AddComponent(new Animation(16, 16, 3, 100));
                baseObject.AddComponent(new DeathAnimationExplosion());
                baseObject.AddComponent(new Camera(_camera));
                break;
            }

            return(baseObject);
        }
Beispiel #7
0
        public void TestDeathAnimation()
        {
            Serial killed = 0x1;
            Serial corpse = 0x1000;

            var data = new DeathAnimation(killed, corpse).Compile();

            Span <byte> expectedData = stackalloc byte[13];
            var         pos          = 0;

            expectedData.Write(ref pos, (byte)0xAF); // Packet ID
            expectedData.Write(ref pos, killed);
            expectedData.Write(ref pos, corpse);
#if NO_LOCAL_INIT
            expectedData.Write(ref pos, 0);
#endif

            AssertThat.Equal(data, expectedData);
        }
Beispiel #8
0
        public override void Initialize(GraphicsDevice GraphicsDevice, SpriteBatch SpriteBatch)
        {
            base.Initialize(GraphicsDevice, SpriteBatch);

            //Initializing HUD component
            HUD = new HUD(ownedMobile, MobileList);

            //Extract terrain geography
            Topography.Initialize(Foreground);

            MobileList.ForEach((x) =>
            {
                //Repositioning the actors in order to accurately reproduce the scenario coordinate showed in the loading screen
                //This must be called here because in this position the background will be already initialized
                x.Position -= Foreground.Pivot;

                //Define the spawning points for each remote mobile
                if (!x.IsPlayable)
                {
                    ((RemoteMovement)x.Movement).DesiredPosition = x.Position;
                }
            });

            //Start all mobiles facing trajectory
            StartMobileFacingTrajectory();

            //Parallax Vectors
            BackgroundRemainingImage = new Vector2(Background.SpriteWidth, Background.SpriteHeight) - Parameter.ScreenResolution;

            //Clear all sfx from the list
            SpecialEffectHandler.Initialize();

            //Clear all pending death animations
            DeathAnimation.Initialize();

            //Start Match
#if !DEBUGSCENE
            ServerInformationHandler.StartMatch();
#endif
        }
Beispiel #9
0
    public virtual void Die(DamagerInflicter.WeaponTypes WeaponType = DamagerInflicter.WeaponTypes.Undefined)
    {
        DeathAnimation da = GetComponent <DeathAnimation>();

        if (da != null)
        {
            da.Spawn(transform.position);
        }

        if (IsPlayer)
        {
            ScreenFx.DeathScreen(WeaponType);

            //as other scripts often reference player, destroying him would cause issues, so im just moving him away from any danger, hopefully
            //if id just kept him where he "dies", enemies would still attack him which would mess with cursor
            transform.position = new Vector3(NavTestStatic.MapWidth - 1, NavTestStatic.MapHeight - 1, 0);
        }
        else
        {
            Destroy(this.gameObject);
        }
    }
Beispiel #10
0
        public override void Update(GameTime gameTime)
        {
            base.Update(gameTime);

            WeatherHandler.Update(gameTime);

            lock (MobileList)
            {
                MobileList.ForEach((m) => m.Update(gameTime));
                HUD.Update(gameTime);
                OnFinalizeUpdatingMobiles?.Invoke();

                MineList.ForEach((x) => x.Update(gameTime));
                ToBeRemovedMineList.ForEach((x) => MineList.Remove(x));
                ToBeRemovedMineList.Clear();

                UpdateBackgroundParallaxPosition();

                ThorSatellite.Update(gameTime);
            }

            DeathAnimation.Update(gameTime);
            SpecialEffectHandler.Update(gameTime);
        }
Beispiel #11
0
        /// <summary>
        /// Analyzes packet and saves it, if its part of the loot.
        /// </summary>
        /// <param name="packet">Packet</param>
        public void AnalyzePacket(Packet packet)
        {
            if (packet is MobileIncoming)
            {
                MobileIncoming p = (MobileIncoming)packet;

                if (!m_Mobiles.ContainsKey(p.Serial))
                {
                    Mobile m = new Mobile(p.Serial);
                    m.Body      = p.ModelId;
                    m.Hue       = (int)p.Hue;
                    m.Notoriety = (Notoriety)p.Notoriety;
                    m.Female    = (p.Flag & 0x2) == 1 ? true : false;
                    m.Blessed   = (p.Flag & 0x8) == 1 ? true : false;

                    m_Mobiles.Add(p.Serial, m);
                }
                else
                {
                    Mobile m = m_Mobiles[p.Serial];

                    m.Body      = p.ModelId;
                    m.Hue       = (int)p.Hue;
                    m.Notoriety = (Notoriety)p.Notoriety;
                    m.Female    = (p.Flag & 0x2) == 1 ? true : false;
                    m.Blessed   = (p.Flag & 0x8) == 1 ? true : false;
                }
            }

            /*else if ( packet is MobileStat )
             * {
             *      MobileStat p = (MobileStat) packet;
             *
             *      if ( m_Mobiles.ContainsKey( p.Serial ) )
             *      {
             *              Mobile m = m_Mobiles[ p.Serial ];
             *
             *              if ( m.Name == null )
             *                      m.Name = p.Name;
             *      }
             * }*/
            else if (packet is DeathAnimation)
            {
                DeathAnimation p = (DeathAnimation)packet;

                if (m_Mobiles.ContainsKey(p.Serial))
                {
                    Mobile m = m_Mobiles[p.Serial];

                    if (m.Corpse == 0)
                    {
                        m.Corpse = p.Corpse;

                        if (!m_Corpses.ContainsKey(p.Corpse))
                        {
                            m_Corpses.Add(p.Corpse, m);
                        }
                    }
                }
            }
            else if (packet is ContainerContentUpdate)
            {
                ContainerContentUpdate p = (ContainerContentUpdate)packet;

                if (m_Corpses.ContainsKey(p.ContSerial))
                {
                    Mobile m = m_Corpses[p.ContSerial];

                    if (m.CorpseContainer == 0)
                    {
                        m.CorpseContainer = p.Serial;
                        m_Filter.AddMobile(m.Name);

                        if (!m_CorpseContainers.ContainsKey(p.Serial))
                        {
                            m_CorpseContainers.Add(p.Serial, m);
                        }
                    }
                }
            }
            else if (packet is ContainerContent)
            {
                ContainerContent p = (ContainerContent)packet;

                foreach (ContainerContent.ContainedItem i in p.Items)
                {
                    if (m_CorpseContainers.ContainsKey(i.ContSerial))
                    {
                        Mobile m = m_CorpseContainers[i.ContSerial];

                        if (!m.Loot.ContainsKey(i.Serial))
                        {
                            Item item;

                            if (!m_Items.ContainsKey(i.Serial))
                            {
                                item = new Item(i.Serial);
                                m_Items.Add(i.Serial, item);
                            }
                            else
                            {
                                item = m_Items[i.Serial];
                            }

                            item.ItemID = i.ItemId;
                            item.Hue    = i.Hue;
                            item.Amount = i.Amount;

                            m.Loot.Add(i.Serial, item);
                        }
                    }
                }
            }
            else if (packet is ObjectProperties)
            {
                ObjectProperties p = (ObjectProperties)packet;

                if (m_Corpses.ContainsKey(p.Serial))
                {
                    Mobile m = m_Corpses[p.Serial];

                    if (m.CorpseName == null && p.Properties.Length > 0)
                    {
                        ObjectProperties.Property prop = p.Properties[0];
                        m.CorpseName = LocalizedList.Construct(prop.Number, prop.Arguments);
                    }
                }
                else if (m_Mobiles.ContainsKey(p.Serial))
                {
                    Mobile m = m_Mobiles[p.Serial];

                    if (p.Properties.Length > 0)
                    {
                        m.Name = LocalizedList.Construct(p.Properties[0].Number, p.Properties[0].Arguments);
                    }
                }
                else
                {
                    Item item;

                    if (!m_Items.ContainsKey(p.Serial))
                    {
                        item = new Item(p.Serial);
                        m_Items.Add(p.Serial, item);
                    }
                    else
                    {
                        item = m_Items[p.Serial];
                    }

                    if (item.Name != null)
                    {
                        return;
                    }

                    for (int i = 0; i < p.Properties.Length; i++)
                    {
                        ObjectProperties.Property prop = p.Properties[i];

                        item.ParseProperty(i, prop.Number, prop.Arguments);
                    }
                }
            }
        }
Beispiel #12
0
        /// Loads required resources for this creature
        public override void load(ContentManager content)
        {
            base.load(content);
            AbilityFiles.ForEach(af => {
                Ability ability = content.Load <Ability>(af);
                if (Abilities.Where(a => a.Title == ability.Title).Count() == 0)
                {
                    addAbility(ability.clone() as Ability);
                }
            });

            Abilities.ForEach(a => a.load(content));

            if (DeathSoundFile != null)
            {
                DeathSound = content.Load <SoundEffect>(DeathSoundFile);
            }

            if (AttackSoundFile != null)
            {
                AttackSound = content.Load <SoundEffect>(AttackSoundFile);
            }

            if (DamageSoundFile != null)
            {
                DamageSound = content.Load <SoundEffect>(DamageSoundFile);
            }

            if (LevelUpSoundFile != null)
            {
                LevelUpSound = content.Load <SoundEffect>(LevelUpSoundFile);
            }

            if (DeathAnimationAsset != null)
            {
                DeathAnimationAsset.load(content);
            }
            if (AttackAnimationAsset != null)
            {
                AttackAnimationAsset.load(content);
            }
            if (DamageAnimationAsset != null)
            {
                DamageAnimationAsset.load(content);
            }
            if (LevelUpAnimationAsset != null)
            {
                LevelUpAnimationAsset.load(content);
            }

            if (DeathAnimation != null)
            {
                DeathAnimation.load(content);
                DeathAnimation.Origin = this;
            }

            if (AttackAnimation != null)
            {
                AttackAnimation.load(content);
                AttackAnimation.Origin = this;
            }

            if (DamageAnimation != null)
            {
                DamageAnimation.load(content);
                DamageAnimation.Origin = this;
            }

            if (LevelUpAnimation != null)
            {
                LevelUpAnimation.load(content);
                LevelUpAnimation.Origin = this;
            }

            if (ClassAsset != null)
            {
                ClassAsset.load(content);
            }
            if (Class != null)
            {
                Class.Creature = this;
            }
        }
Beispiel #13
0
 protected override void OnDeath()
 {
     DeathAnimation.Reset();
     DeathAnimation.Pause();
     HideAndWaitForNextSpawn();
 }
Beispiel #14
0
 // Use this for initialization
 void Start()
 {
     deathSpriteObject = (Instantiate(deathSprite) as GameObject).GetComponent <DeathAnimation>();
     deathSpriteObject.gameObject.SetActive(false);
 }
Beispiel #15
0
 // Start is called before the first frame update
 void Start()
 {
     instance  = this;
     points    = new List <Vector3>();
     nextPoint = 1;
 }