Exemple #1
0
        public static async Task PetCompanion()
        {
            int player = Game.Player.Character.Handle;

            if (API.IsPedInAnyHeli(player))
            {
                Hud.Notification("Don't spawn that poor pet on a heli");
                return;
            }
            else if (API.IsPedInAnyVehicle(player, false))
            {
                var vehicle = API.GetVehiclePedIsIn(player, false);
                if (API.GetVehicleDashboardSpeed(vehicle) > 0.1f)
                {
                    Hud.Notification("Player is in a moving vehicle");
                    return;
                }
            }

            var ped = await Peds.Spawn(Config.PetList, 28);

            Companions.Add(ped);
            await Peds.Arm(ped, null);

            API.SetEntityAsNoLongerNeeded(ref ped);
        }
        private void NewCompanion()
        {
            var newCompanion = new Companion();

            newCompanion.Id = 1;
            if (Companions.Any())
            {
                newCompanion.Id = Companions.Max(x => x.Id) + 1;
            }

            Companions.Add(newCompanion);
            _currentCompanion = newCompanion;
            var newCompanionListItem = new ListBoxItem
            {
                Tag     = newCompanion.Id,
                Content = newCompanion.Id + " - Companion"
            };

            listCompanions.Items.Add(newCompanionListItem);
            foreach (ListBoxItem item in listCompanions.Items)
            {
                var tag = (int)item.Tag;
                if (tag == newCompanion.Id)
                {
                    listCompanions.SelectedItem = item;
                }
            }

            LoadCompanion();
            SaveCompanions();
        }
        private void Build()
        {
            OrbitNum = ComOrbit();

            if (NumOrbits > (OrbitNum / 2))
            {
                NumOrbits = OrbitNum / 2;
            }

            if (OrbitNum == 0)
            {
                Orbits[0].OrbitalType = Orbit.OrbitType.UNAVAILABLE;
            }

            if (OrbitNum == FAR_ORBIT)
            {
                Range  = Common.d6() * 1000;
                SysNat = StarSystem.Nature(true);
                if (SysNat == StarSystem.SystemType.BINARY)
                {
                    NumCompanions = 1;
                    Companions.Add(new CompanionStar(_configuration));
                    AvaialbleOribits(0);
                }
            }
        }
Exemple #4
0
        public static async Task PocceCompanion()
        {
            int ped;
            int player = Game.Player.Character.Handle;

            if (API.IsPedInAnyVehicle(player, false))
            {
                var vehicle = API.GetVehiclePedIsIn(player, false);
                if (Vehicles.GetFreeSeat(vehicle, out int seat))
                {
                    var pocce = Config.PocceList[API.GetRandomIntInRange(0, Config.PocceList.Length)];
                    await Common.RequestModel(pocce);

                    ped = API.CreatePedInsideVehicle(vehicle, 26, pocce, seat, true, false);
                }
                else if (API.GetEntitySpeed(vehicle) > 0.1f)
                {
                    Hud.Notification("Player is in a moving vehicle and there are no free seats");
                    return;
                }
                else
                {
                    ped = await Peds.Spawn(Config.PocceList);
                }
            }
            else
            {
                ped = await Peds.Spawn(Config.PocceList);
            }

            Companions.Add(ped);
            await Peds.Arm(ped, Config.WeaponList);

            API.SetEntityAsNoLongerNeeded(ref ped);
        }
 public void Recruit()
 {
     if (CurrentLocation.Location.PossibleActions?.Contains(Enums.LocationActions.Recruit) == true)
     {
         Companions.Add(Characters.Goblin_Swordsman_LeatherArmor());
     }
 }
    public void UpdateFromBattleGround(BattleGround battleGround)
    {
        RoundNumber = battleGround.Round.RoundNumber;
        RoundStatus = battleGround.RoundStatus;
        TurnType    = battleGround.Round.TurnType;
        TurnStatus  = battleGround.TurnStatus;

        HeroAction       = battleGround.Round.HeroAction;
        SelectedUnitId   = battleGround.Round.SelectedUnit == null ? -1 : battleGround.Round.SelectedUnit.CombatInfo.CombatId;
        SelectedTargetId = battleGround.Round.SelectedTarget == null ? -1 : battleGround.Round.SelectedTarget.CombatInfo.CombatId;

        BattleStatus   = battleGround.BattleStatus;
        SurpriseStatus = battleGround.SurpriseStatus;

        StallingRoundNumber = battleGround.StallingRoundNumber;

        OrderedUnitsCombatIds.Clear();
        for (int i = 0; i < battleGround.Round.OrderedUnits.Count; i++)
        {
            OrderedUnitsCombatIds.Add(battleGround.Round.OrderedUnits[i].CombatInfo.CombatId);
        }

        CombatIds.Clear();
        CombatIds.AddRange(battleGround.CombatIds);
        Companions.Clear();
        for (int i = 0; i < battleGround.Companions.Count; i++)
        {
            Companions.Add(battleGround.Companions[i].GetHashCode());
        }

        Captures.Clear();
        RemovedUnits.Clear();
        for (int i = 0; i < battleGround.Captures.Count; i++)
        {
            Captures.Add(battleGround.Captures[i].GetHashCode());
            if (battleGround.Captures[i].RemoveFromParty)
            {
                var newRemovedUnitData = new FormationUnitSaveData();
                newRemovedUnitData.UpdateFromUnit(battleGround.Captures[i].PrisonerUnit);
                RemovedUnits.Add(newRemovedUnitData);
            }
        }

        Controls.Clear();
        for (int i = 0; i < battleGround.Controls.Count; i++)
        {
            Controls.Add(battleGround.Controls[i].GetHashCode());
        }

        BattleLoot    = battleGround.BattleLoot;
        LastDamaged   = battleGround.LastDamaged;
        LastSkillUsed = battleGround.LastSkillUsed == null ? "" : battleGround.LastSkillUsed;

        MonsterFormation.UpdateFormation(battleGround.MonsterFormation);
    }
Exemple #7
0
 protected void AddFighter(GameFightFighterInformations infos)
 {
     if (infos is GameFightMonsterInformations monsterInfo)
     {
         Monsters.Add(new Monster(monsterInfo.ContextualId, monsterInfo.Disposition.CellId, monsterInfo.Stats,
                                  monsterInfo.TeamId, monsterInfo.Alive, monsterInfo.CreatureGenericId, monsterInfo.CreatureGrade));
     }
     else if (infos is GameFightCompanionInformations companionInfo)
     {
         Companions.Add(new Companion(companionInfo.ContextualId, companionInfo.Disposition.CellId,
                                      companionInfo.Stats, companionInfo.TeamId, companionInfo.Alive, companionInfo.CompanionGenericId,
                                      companionInfo.Level, companionInfo.MasterId));
     }
     else
     {
         Fighters.Add(new Fighter(infos.ContextualId, infos.Disposition.CellId, infos.Stats, infos.TeamId,
                                  infos.Alive));
     }
 }
Exemple #8
0
        public void RefreshMembersList()
        {
            Family.Clear();
            Companions.Clear();
            List <Hero> list = new List <Hero>();

            foreach (Hero noble in _faction.Nobles)
            {
                HeroHelper.SetLastSeenLocation(noble, willUpdateImmediately: true);
                if (noble.IsAlive)
                {
                    if (noble == Hero.MainHero)
                    {
                        list.Insert(0, noble);
                    }
                    else
                    {
                        list.Add(noble);
                    }
                }
            }
            IEnumerable <Hero> enumerable = _faction.Companions.Where((Hero m) => m.IsPlayerCompanion);

            foreach (Hero item in list)
            {
                Family.Add(new WangLordItemVM(item, OnMemberSelection));
            }
            foreach (Hero item2 in enumerable)
            {
                Companions.Add(new WangLordItemVM(item2, OnMemberSelection));
            }
            GameTexts.SetVariable("COMPANION_COUNT", _faction.Companions.Count());
            GameTexts.SetVariable("COMPANION_LIMIT", _faction.CompanionLimit);
            CompanionsText = GameTexts.FindText("str_companions_group").ToString();
            OnMemberSelection(GetDefaultMember());
        }
        /// <summary>
        /// The Update method of a Player. Handles input and "stuff".
        /// </summary>
        public override void Update()
        {
            // if the players HP is 0, thus is dead, change the gamestate to dead
            if (Health <= 0)
            {
                Globals.gamestate = Gamestate.Dead;
            }

            // pressing the P key will pause the game and thus stop updating the game (unpausing in Game1.Update())
            if (Globals.GetKeyUp(Microsoft.Xna.Framework.Input.Keys.P))
            {
                Globals.gamestate = Gamestate.Paused;
            }

            //activating itemeffects on buttonpress for testing
            if (Globals.GetKeyDown(Microsoft.Xna.Framework.Input.Keys.K))
            {
                poopsicle = true;
            }

            //just boomer things
            if (Globals.GetKeyDown(Microsoft.Xna.Framework.Input.Keys.Space) && Level.Player.Bombs > 0)
            {
                //Level.CurrentRoom.Add(new Explosion(Position));
                Level.CurrentRoom.Add(new Bomb(Position));
                Level.Player.Bombs--;

                Globals.sounds.PlaySoundEffect("Sound8");
            }

            //testing items and such
            if (Globals.GetKeyUp(Microsoft.Xna.Framework.Input.Keys.J))
            {
                //Level.CurrentRoom.Add(new Itemstone(new Syringe(Level.CurrentRoom.Position + (Room.Dimensions / 5) * Tile.Size * Globals.Scale),
                //                                               Level.CurrentRoom.Position + (Room.Dimensions / 5) * Tile.Size * Globals.Scale));

                Level.CurrentRoom.Add(new Pot(Level.CurrentRoom.Position + (Room.Dimensions / 5) * Tile.Size * Globals.Scale));
                //Level.Player.Keys += 1;
            }

            //testing environment and enemies
            if (Globals.GetKeyUp(Microsoft.Xna.Framework.Input.Keys.L))
            {
                Level.CurrentRoom.Add(new Flyboss(Level.CurrentRoom.Position + (Room.Dimensions / 3) * Tile.Size * Globals.Scale));
                //Level.CurrentRoom.Add(new Itemstone(new Heart(Level.CurrentRoom.Position + (Room.Dimensions / 3) * Tile.Size * Globals.Scale),
                //                                               Level.CurrentRoom.Position + (Room.Dimensions / 3) * Tile.Size * Globals.Scale));
            }



            // effect used, when the player picks up the Poopsicle item. Spawn 3 flies, that are orbiting around you.
            if (poopsicle)
            {
                Companions.Add(new Flybuddy(new Vector2(Position.X, Position.Y + 55), 0));
                Companions.Add(new Flybuddy(new Vector2(Position.X + 40, Position.Y - 40)));
                Companions.Add(new Flybuddy(new Vector2(Position.X - 40, Position.Y - 40)));
                poopsicle = false;
            }

            // Handle movement input.
            // The movement speed.
            //ushort speed = 350;
            // The velocity.
            _velocity = Vector2.Zero;
            // Up.
            if (Globals.GetKey(Microsoft.Xna.Framework.Input.Keys.W))
            {
                // Play the movement sound.
                //Globals.sounds.PlaySoundEffectOnce("Sound3");
                // Move it up.
                _velocity += -Vector2.UnitY * speed;

                // If there's a top door.
                if (Level.CurrentRoom.Doors[(byte)Directions.Up] != null)
                {
                    // If it touches the top door, it's hidden and the player has more than 0 keys.
                    if (!(Level.CurrentRoom.Doors[(byte)Directions.Up].Kind == DoorKind.Hidden) &&
                        (BumpsInto(Level.CurrentRoom.Doors[(byte)Directions.Up]) &&
                         Math.Abs(Level.CurrentRoom.Doors[(byte)Directions.Up].Position.X - Position.X) <= Door.Width * Scale.X) &&
                        Level.CurrentRoom.Doors[(byte)Directions.Up].State == DoorState.Locked &&
                        Keys > 0)
                    {
                        // The player uses a key.
                        Keys--;
                        // Unlock the door.
                        Level.CurrentRoom.Doors[(byte)Directions.Up].Unlock(true);
                    }
                }
            }
            // Right.
            if (Globals.GetKey(Microsoft.Xna.Framework.Input.Keys.D))
            {
                // Play the movement sound.
                //Globals.sounds.PlaySoundEffectOnce("Sound2");
                // Move it right.
                _velocity += Vector2.UnitX * speed;

                // If there's a right door.
                if (Level.CurrentRoom.Doors[(byte)Directions.Right] != null)
                {
                    // If it touches the right door, it's hidden and the player has more than 0 keys.
                    if (!(Level.CurrentRoom.Doors[(byte)Directions.Right].Kind == DoorKind.Hidden) &&
                        (BumpsInto(Level.CurrentRoom.Doors[(byte)Directions.Right]) &&
                         Math.Abs(Level.CurrentRoom.Doors[(byte)Directions.Right].Position.Y - Position.Y) <= Door.Width * Scale.Y) &&
                        Level.CurrentRoom.Doors[(byte)Directions.Right].State == DoorState.Locked &&
                        Keys > 0)
                    {
                        // The player uses a key.
                        Keys--;
                        // Unlock the door.
                        Level.CurrentRoom.Doors[(byte)Directions.Right].Unlock(true);
                    }
                }
            }
            // Down.
            if (Globals.GetKey(Microsoft.Xna.Framework.Input.Keys.S))
            {
                // Play the movement sound.
                //Globals.sounds.PlaySoundEffectOnce("Sound4");
                // Move it down.
                _velocity += Vector2.UnitY * speed;

                // If there's a bottom door.
                if (Level.CurrentRoom.Doors[(byte)Directions.Down] != null)
                {
                    // If it touches the bottom door, it's hidden and the player has more than 0 keys.
                    if (!(Level.CurrentRoom.Doors[(byte)Directions.Down].Kind == DoorKind.Hidden) &&
                        (BumpsInto(Level.CurrentRoom.Doors[(byte)Directions.Down]) &&
                         Math.Abs(Level.CurrentRoom.Doors[(byte)Directions.Down].Position.X - Position.X) <= Door.Width * Scale.X) &&
                        Level.CurrentRoom.Doors[(byte)Directions.Down].State == DoorState.Locked &&
                        Keys > 0)
                    {
                        // The player uses a key.
                        Keys--;
                        // Unlock the door.
                        Level.CurrentRoom.Doors[(byte)Directions.Down].Unlock(true);
                    }
                }
            }
            // Left.
            if (Globals.GetKey(Microsoft.Xna.Framework.Input.Keys.A))
            {
                // Play the movement sound.
                //Globals.sounds.PlaySoundEffectOnce("Sound1");
                // Move it left.
                _velocity += -Vector2.UnitX * speed;

                // If there's a left door.
                if (Level.CurrentRoom.Doors[(byte)Directions.Left] != null)
                {
                    // If it touches the left door, it's hidden and the player has more than 0 keys.
                    if (!(Level.CurrentRoom.Doors[(byte)Directions.Left].Kind == DoorKind.Hidden) &&
                        (BumpsInto(Level.CurrentRoom.Doors[(byte)Directions.Left]) &&
                         Math.Abs(Level.CurrentRoom.Doors[(byte)Directions.Left].Position.Y - Position.Y) <= Door.Width * Scale.Y) &&
                        Level.CurrentRoom.Doors[(byte)Directions.Left].State == DoorState.Locked &&
                        Keys > 0)
                    {
                        // The player uses a key.
                        Keys--;
                        // Unlock the door.
                        Level.CurrentRoom.Doors[(byte)Directions.Left].Unlock(true);
                    }
                }
            }
            // Choose the proper animation.
            if (Math.Abs(_velocity.X) > Math.Abs(_velocity.Y))
            {
                // If it moves left.
                if (_velocity.X < 0)
                {
                    CurrentAnimation = _walkingAnimations[3];
                }
                // Else it moves right.
                else
                {
                    CurrentAnimation = _walkingAnimations[1];
                }
            }
            // Else it moves up, down or diagonally.
            else
            {
                // If it moves up.
                if (_velocity.Y < 0)
                {
                    CurrentAnimation = _walkingAnimations[0];
                }
                // Else it moves down.
                else if (_velocity.Y > 0)
                {
                    CurrentAnimation = _walkingAnimations[2];
                }
            }
            // Move it.
            if (_velocity != Vector2.Zero)
            {
                //Globals.sounds.PlaySoundEffectOnce("Sound4");
                // Play the walking sound effect.
                if (_walkingSound.State != SoundState.Playing)
                {
                    _walkingSound.Play();
                }
                CurrentAnimation.Resume();
                _velocity = Globals.DegreesToVector2(Globals.Vector2ToDegrees(_velocity)) * speed;
                Move(_velocity);
            }
            else
            {
                CurrentAnimation.Pause();
                CurrentAnimation.SelectFrame(0);
            }


            // handle combat inputs

            damageImunity.UpdateTimer();
            timer.UpdateTimer();
            // up
            if (Globals.GetKey(Microsoft.Xna.Framework.Input.Keys.Up) && timer.Test())
            {
                Globals.sounds.PlaySoundEffect("Attack1");
                Level.CurrentRoom.Add(new BasicAttack(0 - 90, Position));
                timer.ResetToZero();
            }
            // right
            if (Globals.GetKey(Microsoft.Xna.Framework.Input.Keys.Right) && timer.Test())
            {
                Globals.sounds.PlaySoundEffect("Attack1");
                Level.CurrentRoom.Add(new BasicAttack(90 - 90, Position));
                timer.ResetToZero();
            }
            // down
            if (Globals.GetKey(Microsoft.Xna.Framework.Input.Keys.Down) && timer.Test())
            {
                Globals.sounds.PlaySoundEffect("Attack1");
                Level.CurrentRoom.Add(new BasicAttack(180 - 90, Position));
                timer.ResetToZero();
            }
            // left
            if (Globals.GetKey(Microsoft.Xna.Framework.Input.Keys.Left) && timer.Test())
            {
                Globals.sounds.PlaySoundEffect("Attack1");
                Level.CurrentRoom.Add(new BasicAttack(270 - 90, Position));
                timer.ResetToZero();
            }

            // Draw the list of companions
            for (int i = 0; i < Companions.Count; i++)
            {
                Companions[i].Update();
                if (Companions[i].isDestroyed)
                {
                    Companions.RemoveAt(i);
                }
            }

            // Update the Player's layer and stuff.
            base.Update();
        }
    public void ReadBattlegroundData(BinaryReader br)
    {
        RoundNumber = br.ReadInt32();

        RoundStatus    = (RoundStatus)br.ReadInt32();
        TurnType       = (TurnType)br.ReadInt32();
        TurnStatus     = (TurnStatus)br.ReadInt32();
        HeroAction     = (HeroTurnAction)br.ReadInt32();
        BattleStatus   = (BattleStatus)br.ReadInt32();
        SurpriseStatus = (SurpriseStatus)br.ReadInt32();

        StallingRoundNumber = br.ReadInt32();
        SelectedUnitId      = br.ReadInt32();
        SelectedTargetId    = br.ReadInt32();
        LastSkillUsed       = br.ReadString();

        int orderedUnitsCount = br.ReadInt32();

        OrderedUnitsCombatIds.Clear();
        for (int i = 0; i < orderedUnitsCount; i++)
        {
            OrderedUnitsCombatIds.Add(br.ReadInt32());
        }

        int combatIdsCount = br.ReadInt32();

        CombatIds.Clear();
        for (int i = 0; i < combatIdsCount; i++)
        {
            CombatIds.Add(br.ReadInt32());
        }

        int companionsCount = br.ReadInt32();

        Companions.Clear();
        for (int i = 0; i < companionsCount; i++)
        {
            Companions.Add(br.ReadInt32());
        }

        int capturesCount = br.ReadInt32();

        Captures.Clear();
        for (int i = 0; i < capturesCount; i++)
        {
            Captures.Add(br.ReadInt32());
        }

        int controlsCount = br.ReadInt32();

        Controls.Clear();
        for (int i = 0; i < controlsCount; i++)
        {
            Controls.Add(br.ReadInt32());
        }

        int lastDamagedCount = br.ReadInt32();

        LastDamaged.Clear();
        for (int i = 0; i < lastDamagedCount; i++)
        {
            LastDamaged.Add(br.ReadString());
        }

        int battleLootCount = br.ReadInt32();

        BattleLoot.Clear();
        for (int i = 0; i < battleLootCount; i++)
        {
            var newBattleLoot = new LootDefinition()
            {
                Code  = br.ReadString(),
                Count = br.ReadInt32(),
            };
            BattleLoot.Add(newBattleLoot);
        }

        int removedUnitsCount = br.ReadInt32();

        RemovedUnits.Clear();
        for (int i = 0; i < removedUnitsCount; i++)
        {
            var newFormationUnitData = new FormationUnitSaveData();
            newFormationUnitData.ReadFormationUnitData(br);
            RemovedUnits.Add(newFormationUnitData);
        }

        MonsterFormation.ReadFormationData(br);
    }
Exemple #11
0
    public FormationUnit ReplaceUnit(MonsterData data, FormationUnit oldUnit, GameObject newObject, bool roll = false, float carryHp = 0)
    {
        #region Companion
        var companionRecord = Companions.Find(record => record.TargetUnit == oldUnit || record.CompanionUnit == oldUnit);
        if (companionRecord != null)
        {
            Companions.Remove(companionRecord);

            if (companionRecord.CompanionUnit == oldUnit)
            {
                foreach (var buff in companionRecord.CompanionComponent.Buffs)
                {
                    companionRecord.TargetUnit.Character.RemoveSourceBuff(buff, BuffSourceType.Adventure);
                }
                companionRecord.TargetUnit.OverlaySlot.UpdateOverlay();
            }
        }
        #endregion

        FormationUnit newUnit = Instantiate(newObject).GetComponent <FormationUnit>();
        newUnit.Initialize(new Monster(data), oldUnit.Rank, Team.Monsters);
        newUnit.transform.SetParent(oldUnit.transform.parent, false);
        newUnit.transform.position = oldUnit.transform.position;
        newUnit.Party = oldUnit.Party;
        newUnit.Party.Units[newUnit.Party.Units.IndexOf(oldUnit)] = newUnit;
        newUnit.Formation = oldUnit.Formation;
        RaidSceneManager.TorchMeter.ApplyBuffsForUnit(newUnit);
        oldUnit.OverlaySlot.LockOnUnit(newUnit);
        oldUnit.RankSlot.PutInSlot(newUnit);
        if (carryHp != 0)
        {
            newUnit.Character.Health.ValueRatio = carryHp;
        }
        newUnit.CombatInfo.PrepareForBattle(oldUnit.CombatInfo.CombatId, newUnit.Character as Monster, true);

        DarkestSoundManager.ExecuteNarration("change_monster_class", NarrationPlace.Raid,
                                             oldUnit.Character.Class, newUnit.Character.Class);

        if (!newUnit.RankSlot.Ranks.facingRight)
        {
            newUnit.InstantFlip();
        }

        newUnit.ResetAnimations();
        if (roll)
        {
            for (int i = 0; i < Round.OrderedUnits.Count; i++)
            {
                if (Round.OrderedUnits[i] == oldUnit)
                {
                    Round.OrderedUnits[i] = newUnit;
                }
            }
        }
        else
        {
            Round.OrderedUnits.RemoveAll(unit => unit == oldUnit);
        }

        if (SharedHealth.IsActive && data.SharedHealth != null)
        {
            SharedHealth.SharedUnits.Remove(oldUnit);
            SharedHealth.SharedUnits.Add(newUnit);
            newUnit.Character[AttributeType.HitPoints, true] = SharedHealth.Health;
        }

        Destroy(oldUnit.gameObject);

        #region Companion Check
        if (data.Companion != null)
        {
            var companion = newUnit.Formation.party.Units.Find(unit => unit.Character.Class == data.Companion.MonsterClass);
            if (companion != null)
            {
                Companions.Add(new CompanionRecord(newUnit, companion));
                foreach (var buff in data.Companion.Buffs)
                {
                    newUnit.Character.AddBuff(new BuffInfo(buff, BuffDurationType.Raid,
                                                           BuffSourceType.Adventure, 3));
                }
                newUnit.OverlaySlot.UpdateOverlay();
            }
        }
        for (int i = 0; i < newUnit.Party.Units.Count; i++)
        {
            if (newUnit.Party.Units[i] != newUnit && newUnit.Party.Units[i].Character.IsMonster)
            {
                var monster = newUnit.Party.Units[i].Character as Monster;
                if (monster.Data.Companion != null)
                {
                    var companion = newUnit.Party.Units.Find(unit => unit.Character.Class == monster.Data.Companion.MonsterClass);
                    if (companion != null)
                    {
                        Companions.Add(new CompanionRecord(newUnit.Party.Units[i], companion));
                        foreach (var buff in monster.Data.Companion.Buffs)
                        {
                            newUnit.Party.Units[i].Character.AddBuff(new BuffInfo(buff, BuffDurationType.Raid,
                                                                                  BuffSourceType.Adventure, 3));
                        }
                        newUnit.Party.Units[i].OverlaySlot.UpdateOverlay();
                    }
                }
            }
        }
        #endregion

        return(newUnit);
    }
Exemple #12
0
    public void SummonUnit(MonsterData monsterData, GameObject unitObject, int targetRank, bool initiativeRoll, bool canSpawnLoot)
    {
        FormationUnit newUnit = Instantiate(unitObject).GetComponent <FormationUnit>();

        newUnit.Initialize(new Monster(monsterData), targetRank, Team.Monsters);
        newUnit.transform.SetParent(MonsterParty.transform, false);
        newUnit.RectTransform.position = MonsterFormation.rankHolder.rankMarkSlots[targetRank - 1].transform.position;
        newUnit.Party     = MonsterParty;
        newUnit.Formation = MonsterFormation;
        newUnit.CombatInfo.PrepareForBattle(PickId(), newUnit.Character as Monster, canSpawnLoot);
        RaidSceneManager.TorchMeter.ApplyBuffsForUnit(newUnit);

        if (!MonsterFormation.ranks.facingRight)
        {
            newUnit.InstantFlip();
        }

        newUnit.ResetAnimations();

        if (newUnit.Formation.AvailableFreeSpace >= newUnit.Size)
        {
            newUnit.Formation.SpawnUnit(newUnit, targetRank);
            if (initiativeRoll)
            {
                Round.InsertInitiativeRoll(newUnit);
            }
            #region Spawn Check
            if (monsterData.Spawn != null)
            {
                for (int i = 0; i < monsterData.Spawn.Effects.Count; i++)
                {
                    for (int j = 0; j < monsterData.Spawn.Effects[i].SubEffects.Count; j++)
                    {
                        monsterData.Spawn.Effects[i].SubEffects[j].ApplyInstant(newUnit, newUnit, monsterData.Spawn.Effects[i]);
                    }
                }
                newUnit.OverlaySlot.UpdateOverlay();
            }
            #endregion
            #region Companion Check
            if (monsterData.Companion != null)
            {
                var companion = newUnit.Formation.party.Units.Find(unit =>
                                                                   unit.Character.Class == monsterData.Companion.MonsterClass);
                if (companion != null)
                {
                    Companions.Add(new CompanionRecord(newUnit, companion));
                    foreach (var buff in monsterData.Companion.Buffs)
                    {
                        newUnit.Character.AddBuff(new BuffInfo(buff, BuffDurationType.Raid,
                                                               BuffSourceType.Adventure, 3));
                    }
                    newUnit.OverlaySlot.UpdateOverlay();
                }
            }
            for (int i = 0; i < newUnit.Party.Units.Count; i++)
            {
                if (newUnit.Party.Units[i] != newUnit && newUnit.Party.Units[i].Character.IsMonster)
                {
                    var monster = newUnit.Party.Units[i].Character as Monster;
                    if (monster.Data.Companion != null)
                    {
                        var companion = newUnit.Party.Units.Find(unit =>
                                                                 unit.Character.Class == monster.Data.Companion.MonsterClass);
                        if (companion != null)
                        {
                            Companions.Add(new CompanionRecord(newUnit.Party.Units[i], companion));
                            foreach (var buff in monster.Data.Companion.Buffs)
                            {
                                newUnit.Party.Units[i].Character.AddBuff(new BuffInfo(buff, BuffDurationType.Raid,
                                                                                      BuffSourceType.Adventure, 3));
                            }
                            newUnit.Party.Units[i].OverlaySlot.UpdateOverlay();
                        }
                    }
                }
            }
            #endregion
        }
        else if (newUnit.Formation.AvailableSummonSpace >= newUnit.Size)
        {
            var purgingCandidates = new List <FormationUnit>(newUnit.Formation.party.Units);
            purgingCandidates.Sort((x, y) =>
            {
                if (Mathf.Abs(x.Rank - targetRank) == Mathf.Abs(y.Rank - targetRank))
                {
                    return(0);
                }
                if (Mathf.Abs(x.Rank - targetRank) < Mathf.Abs(y.Rank - targetRank))
                {
                    return(1);
                }
                else
                {
                    return(-1);
                }
            });

            for (int i = purgingCandidates.Count - 1; i >= 0; i--)
            {
                if (purgingCandidates[i].Character.IsMonster && purgingCandidates[i].Character.BattleModifiers.CanBeSummonRank)
                {
                    RaidSceneManager.Instanse.SummonPurging(purgingCandidates[i]);
                    if (newUnit.Formation.AvailableFreeSpace >= newUnit.Size)
                    {
                        newUnit.Formation.SpawnUnit(newUnit, targetRank);
                        if (initiativeRoll)
                        {
                            Round.InsertInitiativeRoll(newUnit);
                        }
                        #region Spawn Check
                        if (monsterData.Spawn != null)
                        {
                            for (int k = 0; k < monsterData.Spawn.Effects.Count; k++)
                            {
                                for (int j = 0; j < monsterData.Spawn.Effects[k].SubEffects.Count; j++)
                                {
                                    monsterData.Spawn.Effects[k].SubEffects[j].ApplyInstant(newUnit, newUnit, monsterData.Spawn.Effects[k]);
                                }
                            }
                            newUnit.OverlaySlot.UpdateOverlay();
                        }
                        #endregion
                        #region Companion Check
                        if (monsterData.Companion != null)
                        {
                            var companion = newUnit.Formation.party.Units.Find(unit =>
                                                                               unit.Character.Class == monsterData.Companion.MonsterClass);
                            if (companion != null)
                            {
                                Companions.Add(new CompanionRecord(newUnit, companion));
                                foreach (var buff in monsterData.Companion.Buffs)
                                {
                                    newUnit.Character.AddBuff(new BuffInfo(buff, BuffDurationType.Raid,
                                                                           BuffSourceType.Adventure, 3));
                                }
                                newUnit.OverlaySlot.UpdateOverlay();
                            }
                        }
                        for (int j = 0; j < newUnit.Party.Units.Count; j++)
                        {
                            if (newUnit.Party.Units[j] != newUnit && newUnit.Party.Units[j].Character.IsMonster)
                            {
                                var monster = newUnit.Party.Units[j].Character as Monster;
                                if (monster.Data.Companion != null)
                                {
                                    var companion = newUnit.Party.Units.Find(unit =>
                                                                             unit.Character.Class == monster.Data.Companion.MonsterClass);
                                    if (companion != null)
                                    {
                                        Companions.Add(new CompanionRecord(newUnit.Party.Units[j], companion));
                                        foreach (var buff in monster.Data.Companion.Buffs)
                                        {
                                            newUnit.Party.Units[j].Character.AddBuff(new BuffInfo(buff, BuffDurationType.Raid,
                                                                                                  BuffSourceType.Adventure, 3));
                                        }
                                        newUnit.Party.Units[j].OverlaySlot.UpdateOverlay();
                                    }
                                }
                            }
                        }
                        #endregion
                        return;
                    }
                }
            }
            ReturnId(newUnit.CombatInfo.CombatId);
            Debug.LogError("Not enough summon space for " + newUnit.name);
            Destroy(newUnit.gameObject);
        }
        else
        {
            ReturnId(newUnit.CombatInfo.CombatId);
            Debug.LogError("Not enough summon space for " + newUnit.name);
            Destroy(newUnit.gameObject);
        }
    }
Exemple #13
0
    public void LoadEffects(BattleGroundSaveData battleSaveData)
    {
        #region Load Statuses and Immobilize
        for (int i = 0; i < HeroParty.Units.Count; i++)
        {
            if (HeroParty.Units[i].Character[StatusType.Stun].IsApplied)
            {
                HeroParty.Units[i].SetHalo("stunned");
            }
            else if (HeroParty.Units[i].CombatInfo.IsSurprised)
            {
                HeroParty.Units[i].SetHalo("surprised");
            }

            if (HeroParty.Units[i].CombatInfo.IsImmobilized)
            {
                HeroParty.Units[i].SetDefendAnimation(true);
            }

            if (HeroParty.Units[i].Character.IsMonster == false)
            {
                var hero = HeroParty.Units[i].Character as Hero;
                if (hero[StatusType.DeathsDoor].IsApplied)
                {
                    hero.ApplyDeathDoor();
                }
                else if (hero[StatusType.DeathRecovery].IsApplied)
                {
                    hero.ApplyMortality();
                }
            }
        }
        for (int i = 0; i < MonsterParty.Units.Count; i++)
        {
            if (MonsterParty.Units[i].Character[StatusType.Stun].IsApplied)
            {
                MonsterParty.Units[i].SetHalo("stunned");
            }
            else if (MonsterParty.Units[i].CombatInfo.IsSurprised)
            {
                MonsterParty.Units[i].SetHalo("surprised");
            }

            if (MonsterParty.Units[i].CombatInfo.IsImmobilized)
            {
                MonsterParty.Units[i].SetDefendAnimation(true);
            }

            if (MonsterParty.Units[i].Character.IsMonster == false)
            {
                MonsterParty.Units[i].SetCombatAnimation(true);
                var hero = MonsterParty.Units[i].Character as Hero;
                if (hero[StatusType.DeathsDoor].IsApplied)
                {
                    hero.ApplyDeathDoor();
                }
                else if (hero[StatusType.DeathRecovery].IsApplied)
                {
                    hero.ApplyMortality();
                }
            }
        }
        #endregion

        #region Load Captures
        for (int i = 0; i < battleSaveData.Captures.Count; i++)
        {
            CaptureRecord newCaptureRecord = new CaptureRecord();
            int           prisonerId       = newCaptureRecord.GetHashPrisonerId(battleSaveData.Captures[i]);
            int           captorId         = newCaptureRecord.GetHashCaptorId(battleSaveData.Captures[i]);
            newCaptureRecord.RemoveFromParty = newCaptureRecord.GetHashRemoveFromParty(battleSaveData.Captures[i]);

            if (newCaptureRecord.RemoveFromParty == false)
            {
                FormationUnit prisoner = FindById(prisonerId);
                FormationUnit captor   = FindById(captorId);
                newCaptureRecord.PrisonerUnit = prisoner;
                newCaptureRecord.CaptorUnit   = captor;
                prisoner.SetCaptureEffect(captor);
                Captures.Add(newCaptureRecord);
            }
            else
            {
                FormationUnit prisoner = loadedRemovedPrisoners.Find(removedUnit => removedUnit.CombatInfo.CombatId == prisonerId);
                FormationUnit captor   = FindById(captorId);
                prisoner.RectTransform.position = captor.RectTransform.position;
                newCaptureRecord.PrisonerUnit   = prisoner;
                newCaptureRecord.CaptorUnit     = captor;
                Captures.Add(newCaptureRecord);
            }
        }
        #endregion

        #region Load Companions
        for (int i = 0; i < battleSaveData.Companions.Count; i++)
        {
            CompanionRecord newCompanionRecord = new CompanionRecord();
            int             companionId        = newCompanionRecord.GetHashCompanionId(battleSaveData.Companions[i]);
            int             targetId           = newCompanionRecord.GetHashTargetId(battleSaveData.Companions[i]);

            FormationUnit companion = FindById(companionId);
            FormationUnit target    = FindById(targetId);
            newCompanionRecord.CompanionUnit = companion;
            newCompanionRecord.TargetUnit    = target;
            Companions.Add(newCompanionRecord);
        }
        #endregion

        #region Load Controls
        for (int i = 0; i < battleSaveData.Controls.Count; i++)
        {
            ControlRecord newControlRecord = new ControlRecord();
            int           prisonerId       = newControlRecord.GetHashPrisonerId(battleSaveData.Controls[i]);
            int           controllerId     = newControlRecord.GetHashControlId(battleSaveData.Controls[i]);
            newControlRecord.DurationLeft = newControlRecord.GetHashDurationLeft(battleSaveData.Controls[i]);
            FormationUnit prisoner   = FindById(prisonerId);
            FormationUnit controller = FindById(controllerId);
            newControlRecord.PrisonerUnit = prisoner;
            newControlRecord.ControllUnit = controller;
            Controls.Add(newControlRecord);
        }
        #endregion

        loadedRemovedPrisoners.Clear();

        RaidSceneManager.Formations.HeroOverlay.UpdateOverlay();
        RaidSceneManager.Formations.monsters.overlay.UpdateOverlay();
    }