Exemple #1
0
        protected virtual bool DoCload(string rawParameters, params CommandParameter[] parameters)
        {
            if (parameters.Length == 0 || !parameters[0].IsNumber)
            {
                Send("Syntax: cload <id>");
                return(true);
            }

            CharacterBlueprint characterBlueprint = DependencyContainer.Instance.GetInstance <IWorld>().GetCharacterBlueprint(parameters[0].AsNumber);

            if (characterBlueprint == null)
            {
                Send("No character with that id.");
                return(true);
            }

            ICharacter character = DependencyContainer.Instance.GetInstance <IWorld>().AddCharacter(Guid.NewGuid(), characterBlueprint, Impersonating.Room);

            if (character == null)
            {
                Send("Character cannot be created.");
                DependencyContainer.Instance.GetInstance <IServer>().Wiznet($"DoCload: character with id {parameters[0].AsNumber} cannot be created", WiznetFlags.Bugs, AdminLevels.Implementor);
                return(true);
            }

            DependencyContainer.Instance.GetInstance <IServer>().Wiznet($"{DisplayName} loads {character.DebugName}.", WiznetFlags.Load);

            Impersonating.Act(ActOptions.ToAll, "{0:N} {0:h} created {1:n}!", Impersonating, character);
            Send("Ok.");

            return(true);
        }
Exemple #2
0
 public void AddCharacterBlueprint(CharacterBlueprint blueprint)
 {
     if (_characterBlueprints.ContainsKey(blueprint.Id))
     {
         Log.Default.WriteLine(LogLevels.Error, $"Character blueprint duplicate {blueprint.Id}!!!");
     }
     else
     {
         _characterBlueprints.Add(blueprint.Id, blueprint);
     }
 }
Exemple #3
0
        public ICharacter AddCharacter(Guid guid, CharacterBlueprint blueprint, IRoom room) // NPC
        {
            if (blueprint == null)
            {
                throw new ArgumentNullException(nameof(blueprint));
            }
            ICharacter character = new Character.Character(guid, blueprint, room);

            _characters.Add(character);
            return(character);
        }
Exemple #4
0
    public override void RegisterSpawnpoint()
    {
        GridLocation = GridLocation.VectorToGrid(transform.position);

        if (EditorManager.InEditor)
        {
            return;
        }

        CharacterBlueprint = new CharacterBlueprint(EnemyType);

        MazeLevelGameplayManager.Instance.Level.EnemyCharacterSpawnpoints.Add(this);
    }
Exemple #5
0
 public Quest(QuestBlueprint blueprint, ICharacter character, ICharacter giver)
 {
     _character            = character;
     Blueprint             = blueprint;
     Giver                 = giver;
     _killObjectivesKilled = blueprint.KillObjectives?.ToDictionary(x => x.CharacterBlueprintId, x => 0);
     _objectives           = new List <QuestObjectiveBase>();
     if (Blueprint.ItemObjectives != null)
     {
         foreach (QuestItemObjective itemObjective in Blueprint.ItemObjectives)
         {
             ItemBlueprintBase itemBlueprint = Repository.World.GetItemBlueprint(itemObjective.ItemBlueprintId);
             if (itemBlueprint != null)
             {
                 _objectives.Add(new ItemQuestObjective
                 {
                     Blueprint = itemBlueprint,
                     Count     = character.Content.Where(x => x.Blueprint != null).Count(x => x.Blueprint.Id == itemObjective.ItemBlueprintId), // should always be 0
                     Total     = itemObjective.Count
                 });
             }
             else
             {
                 Log.Default.WriteLine(LogLevels.Warning, $"Item objective {itemObjective.ItemBlueprintId} doesn't exist for quest {blueprint.Id}");
             }
         }
     }
     if (Blueprint.KillObjectives != null)
     {
         foreach (QuestKillObjective killObjective in Blueprint.KillObjectives)
         {
             CharacterBlueprint characterBlueprint = Repository.World.GetCharacterBlueprint(killObjective.CharacterBlueprintId);
             if (characterBlueprint != null)
             {
                 _objectives.Add(new KillQuestObjective
                 {
                     Blueprint = characterBlueprint,
                     Count     = 0,
                     Total     = killObjective.Count
                 });
             }
             else
             {
                 Log.Default.WriteLine(LogLevels.Warning, $"Item objective {killObjective.CharacterBlueprintId} doesn't exist for quest {blueprint.Id}");
             }
         }
     }
 }
Exemple #6
0
    void SelectCharacter()
    {
        if (cursor.currentTarget.GetComponent <CharacterBox>() == null)
        {
            return;
        }
        currentCharacter = cursor.currentTarget.GetComponent <CharacterBox>().character;
        CharacterBlueprint blueprint = Assets.Get(currentCharacter);

        currentSelectionName.text      = blueprint.name;
        currentSelectionDisplay.sprite = blueprint.uiInfo.bigSprite;
        currentSelectionDisplay.color  = new Color(1f, 1f, 1f, 1f);
        hasMadeSelection = true;

        UpdateEntitas(); //will be moved to when you 'Press Start'
    }
Exemple #7
0
    void Update()
    {
        if (cursor == null)
        {
            cursor = CursorBehaviour.allCursors[listener.playerId];
            ToggleVisibility(hasJoinedTheGame);
        }

        if (!hasMadeSelection && cursor.currentTarget != null)
        {
            if (cursor.currentTarget.GetComponent <CharacterBox>() == null)
            {
                return;
            }

            Characters currentCharacter = cursor.currentTarget.GetComponent <CharacterBox> ().character;

            currentSelectionDisplay.sprite = Assets.Get(currentCharacter).uiInfo.bigSprite;
            currentSelectionDisplay.color  = new Color(1f, 1f, 1f, 0.5f);

            CharacterBlueprint blueprint = Assets.Get(currentCharacter);
            currentSelectionName.text = blueprint.name;
        }
    }
Exemple #8
0
        //private static void TestSecondWindow()
        //{
        //    ProcessStartInfo psi = new ProcessStartInfo("cmd.exe")
        //    {
        //        RedirectStandardError = true,
        //        RedirectStandardInput = true,
        //        RedirectStandardOutput = true,
        //        UseShellExecute = false,
        //        CreateNoWindow = true,
        //        WindowStyle = ProcessWindowStyle.Normal
        //    };

        //    Process p = Process.Start(psi);

        //    StreamWriter sw = p.StandardInput;
        //    StreamReader sr = p.StandardOutput;

        //    sw.WriteLine("Hello world!");
        //    sr.Close();
        //}

        private static void CreateDummyWorld()
        {
            // Blueprints
            // Rooms
            RoomBlueprint room1Blueprint = new RoomBlueprint
            {
                Id          = 1,
                Name        = "room1",
                Description = "My first room"
            };
            RoomBlueprint room2Blueprint = new RoomBlueprint
            {
                Id          = 2,
                Name        = "room2",
                Description = "My second room"
            };
            // Characters
            CharacterBlueprint mob2Blueprint = new CharacterBlueprint
            {
                Id               = 2,
                Name             = "mob2",
                ShortDescription = "Second mob (female)",
                Description      = "Second mob (female) is here",
                Sex              = Sex.Female,
                Level            = 10
            };
            CharacterBlueprint mob3Blueprint = new CharacterBlueprint
            {
                Id               = 3,
                Name             = "mob3",
                ShortDescription = "Third mob (male)",
                Description      = "Third mob (male) is here",
                Sex              = Sex.Male,
                Level            = 10
            };
            CharacterBlueprint mob4Blueprint = new CharacterBlueprint
            {
                Id               = 4,
                Name             = "mob4",
                ShortDescription = "Fourth mob (neutral)",
                Description      = "Fourth mob (neutral) is here",
                Sex              = Sex.Neutral,
                Level            = 10
            };
            CharacterBlueprint mob5Blueprint = new CharacterBlueprint
            {
                Id               = 5,
                Name             = "mob5",
                ShortDescription = "Fifth mob (female)",
                Description      = "Fifth mob (female) is here",
                Sex              = Sex.Female,
                Level            = 10
            };
            ItemContainerBlueprint item1Blueprint = new ItemContainerBlueprint
            {
                Id               = 1,
                Name             = "item1",
                ShortDescription = "First item (container)",
                Description      = "The first item (container) has been left here.",
                ItemCount        = 10,
                WeightMultiplier = 100
            };
            ItemWeaponBlueprint item2Blueprint = new ItemWeaponBlueprint
            {
                Id               = 2,
                Name             = "item2",
                ShortDescription = "Second item (weapon)",
                Description      = "The second item (weapon) has been left here.",
                Type             = WeaponTypes.Axe1H,
                DiceCount        = 10,
                DiceValue        = 20,
                DamageType       = SchoolTypes.Fire,
                WearLocation     = WearLocations.Wield
            };
            ItemArmorBlueprint item3Blueprint = new ItemArmorBlueprint
            {
                Id               = 3,
                Name             = "item3",
                ShortDescription = "Third item (armor|feet)",
                Description      = "The third item (armor|feet) has been left here.",
                Armor            = 100,
                ArmorKind        = ArmorKinds.Mail,
                WearLocation     = WearLocations.Feet
            };
            ItemLightBlueprint item4Blueprint = new ItemLightBlueprint
            {
                Id               = 4,
                Name             = "item4",
                ShortDescription = "Fourth item (light)",
                Description      = "The fourth item (light) has been left here.",
                DurationHours    = -1,
                WearLocation     = WearLocations.Light
            };
            ItemWeaponBlueprint item5Blueprint = new ItemWeaponBlueprint
            {
                Id               = 5,
                Name             = "item5",
                ShortDescription = "Fifth item (weapon)",
                Description      = "The fifth item (weapon) has been left here.",
                Type             = WeaponTypes.Sword1H,
                DiceCount        = 5,
                DiceValue        = 40,
                DamageType       = SchoolTypes.Physical,
                WearLocation     = WearLocations.Wield
            };

            //
            ServerOptions.CorpseBlueprint = new ItemCorpseBlueprint();

            // World
            IArea midgaard = DependencyContainer.Instance.GetInstance <IWorld>().Areas.FirstOrDefault(x => x.DisplayName == "Midgaard");
            IRoom room1    = DependencyContainer.Instance.GetInstance <IWorld>().AddRoom(Guid.NewGuid(), room1Blueprint, midgaard);
            IRoom room2    = DependencyContainer.Instance.GetInstance <IWorld>().AddRoom(Guid.NewGuid(), room2Blueprint, midgaard);

            DependencyContainer.Instance.GetInstance <IWorld>().AddExit(room1, room2, null, ExitDirections.North);
            DependencyContainer.Instance.GetInstance <IWorld>().AddExit(room2, room1, null, ExitDirections.North);

            //ICharacter mob1 = DependencyContainer.Instance.GetInstance<IWorld>().AddCharacter(Guid.NewGuid(), "Mob1", Repository.ClassManager["Mage"], Repository.RaceManager["Troll"], Sex.Male, room1); // playable
            ICharacter mob2 = DependencyContainer.Instance.GetInstance <IWorld>().AddCharacter(Guid.NewGuid(), mob2Blueprint, room1);
            ICharacter mob3 = DependencyContainer.Instance.GetInstance <IWorld>().AddCharacter(Guid.NewGuid(), mob3Blueprint, room2);
            ICharacter mob4 = DependencyContainer.Instance.GetInstance <IWorld>().AddCharacter(Guid.NewGuid(), mob4Blueprint, room2);
            ICharacter mob5 = DependencyContainer.Instance.GetInstance <IWorld>().AddCharacter(Guid.NewGuid(), mob5Blueprint, room2);

            IItemContainer item1     = DependencyContainer.Instance.GetInstance <IWorld>().AddItemContainer(Guid.NewGuid(), item1Blueprint, room1);
            IItemContainer item1Dup1 = DependencyContainer.Instance.GetInstance <IWorld>().AddItemContainer(Guid.NewGuid(), item1Blueprint, room2);
            IItemWeapon    item2     = DependencyContainer.Instance.GetInstance <IWorld>().AddItemWeapon(Guid.NewGuid(), item2Blueprint, mob2);
            IItemArmor     item3     = DependencyContainer.Instance.GetInstance <IWorld>().AddItemArmor(Guid.NewGuid(), item3Blueprint, item1Dup1);
            //IItemLight item4 = DependencyContainer.Instance.GetInstance<IWorld>().AddItemLight(Guid.NewGuid(), item4Blueprint, mob1);
            //IItemWeapon item5 = DependencyContainer.Instance.GetInstance<IWorld>().AddItemWeapon(Guid.NewGuid(), item5Blueprint, mob1);
            //IItemContainer item1Dup2 = DependencyContainer.Instance.GetInstance<IWorld>().AddItemContainer(Guid.NewGuid(), item1Blueprint, mob1);
            IItemArmor item3Dup1 = DependencyContainer.Instance.GetInstance <IWorld>().AddItemArmor(Guid.NewGuid(), item3Blueprint, mob3);
            IItemLight item4Dup1 = DependencyContainer.Instance.GetInstance <IWorld>().AddItemLight(Guid.NewGuid(), item4Blueprint, mob4);

            // Equip weapon on mob2
            mob2.Equipments.FirstOrDefault(x => x.Slot == EquipmentSlots.Wield).Item = item2;
            item2.ChangeContainer(null);
            item2.ChangeEquipedBy(mob2);
        }
Exemple #9
0
        private static void CreateMidgaard()
        {
            MysteryImporter importer = new MysteryImporter();

            importer.Load(@"D:\GitHub\OldMud\area\midgaard.are");
            importer.Parse();
            //MysteryImporter importer = new MysteryImporter();
            //string path = @"D:\GitHub\OldMud\area";
            //string fileList = Path.Combine(path, "area.lst");
            //string[] areaFilenames = File.ReadAllLines(fileList);
            //foreach (string areaFilename in areaFilenames)
            //{
            //    if (areaFilename.Contains("$"))
            //        break;
            //    string areaFullName = Path.Combine(path, areaFilename);
            //    importer.Load(areaFullName);
            //    importer.Parse();
            //}

            Dictionary <int, IArea> areasByVnums = new Dictionary <int, IArea>();
            Dictionary <int, IRoom> roomsByVNums = new Dictionary <int, IRoom>();

            // Create Areas
            foreach (AreaData importedArea in importer.Areas)
            {
                // TODO: levels
                IArea area = DependencyContainer.Instance.GetInstance <IWorld>().AddArea(Guid.NewGuid(), importedArea.Name, 1, 99, importedArea.Builders, importedArea.Credits);
                areasByVnums.Add(importedArea.VNum, area);
            }

            // Create Rooms
            foreach (RoomData importedRoom in importer.Rooms)
            {
                IArea         area          = areasByVnums[importedRoom.AreaVnum];
                RoomBlueprint roomBlueprint = new RoomBlueprint
                {
                    Id          = importedRoom.VNum,
                    Name        = importedRoom.Name,
                    Description = importedRoom.Description,
                };
                IRoom room = DependencyContainer.Instance.GetInstance <IWorld>().AddRoom(Guid.NewGuid(), roomBlueprint, area);
                roomsByVNums.Add(importedRoom.VNum, room);
            }
            // Create Exits
            foreach (RoomData room in importer.Rooms)
            {
                for (int i = 0; i < RoomData.MaxExits - 1; i++)
                {
                    ExitData exit = room.Exits[i];
                    if (exit != null)
                    {
                        IRoom from;
                        roomsByVNums.TryGetValue(room.VNum, out from);
                        IRoom to;
                        roomsByVNums.TryGetValue(exit.DestinationVNum, out to);
                        if (from == null)
                        {
                            Log.Default.WriteLine(LogLevels.Error, "Origin room not found for vnum {0}", room.VNum);
                        }
                        else if (to == null)
                        {
                            Log.Default.WriteLine(LogLevels.Error, "Destination room not found for vnum {0}", room.VNum);
                        }
                        else
                        {
                            DependencyContainer.Instance.GetInstance <IWorld>().AddExit(from, to, null, (ExitDirections)i);
                        }
                    }
                }
            }
            //// Handle resets
            //foreach (RoomData importedRoom in importer.Rooms.Where(x => x.Resets.Any()))
            //{
            //    IRoom room;
            //    roomsByVNums.TryGetValue(importedRoom.VNum, out room);
            //    foreach (ResetData reset in importedRoom.Resets)
            //    {
            //        switch (reset.Command)
            //        {
            //            case 'M':
            //                MobileData mob = importer.Mobiles.FirstOrDefault(x => x.VNum == reset.Arg1);
            //                if (mob != null)
            //                    DependencyContainer.Instance.GetInstance<IWorld>().AddCharacter(Guid.NewGuid(), mob.Name, room);
            //                break;
            //            case 'O':
            //                ObjectData obj = importer.Objects.FirstOrDefault(x => x.VNum == reset.Arg1);
            //                if (obj != null) // TODO: itemType
            //                    DependencyContainer.Instance.GetInstance<IWorld>().AddItemContainer(Guid.NewGuid(), obj.Name, room);
            //                break;
            //            // TODO: other command  P, E, G, D, R, Z
            //        }
            //    }
            //}

            CharacterBlueprint mob2Blueprint = new CharacterBlueprint
            {
                Id               = 2,
                Name             = "mob2",
                ShortDescription = "Second mob (female)",
                Description      = "Second mob (female) is here",
                Sex              = Sex.Female,
                Level            = 10
            };
            CharacterBlueprint mob3Blueprint = new CharacterBlueprint
            {
                Id               = 3,
                Name             = "mob3",
                ShortDescription = "Third mob (male)",
                Description      = "Third mob (male) is here",
                Sex              = Sex.Male,
                Level            = 10
            };
            CharacterBlueprint mob4Blueprint = new CharacterBlueprint
            {
                Id               = 4,
                Name             = "mob4",
                ShortDescription = "Fourth mob (neutral)",
                Description      = "Fourth mob (neutral) is here",
                Sex              = Sex.Neutral,
                Level            = 10
            };
            CharacterBlueprint mob5Blueprint = new CharacterBlueprint
            {
                Id               = 5,
                Name             = "mob5",
                ShortDescription = "Fifth mob (female)",
                Description      = "Fifth mob (female) is here",
                Sex              = Sex.Female,
                Level            = 10
            };
            ItemContainerBlueprint item1Blueprint = new ItemContainerBlueprint
            {
                Id               = 1,
                Name             = "item1",
                ShortDescription = "First item (container)",
                Description      = "The first item (container) has been left here.",
                ItemCount        = 10,
                WeightMultiplier = 100
            };
            ItemWeaponBlueprint item2Blueprint = new ItemWeaponBlueprint
            {
                Id               = 2,
                Name             = "item2",
                ShortDescription = "Second item (weapon)",
                Description      = "The second item (weapon) has been left here.",
                Type             = WeaponTypes.Axe1H,
                DiceCount        = 10,
                DiceValue        = 20,
                DamageType       = SchoolTypes.Fire,
                WearLocation     = WearLocations.Wield
            };
            ItemArmorBlueprint item3Blueprint = new ItemArmorBlueprint
            {
                Id               = 3,
                Name             = "item3",
                ShortDescription = "Third item (armor|feet)",
                Description      = "The third item (armor|feet) has been left here.",
                Armor            = 100,
                ArmorKind        = ArmorKinds.Mail,
                WearLocation     = WearLocations.Feet
            };
            ItemLightBlueprint item4Blueprint = new ItemLightBlueprint
            {
                Id               = 4,
                Name             = "item4",
                ShortDescription = "Fourth item (light)",
                Description      = "The fourth item (light) has been left here.",
                DurationHours    = -1,
                WearLocation     = WearLocations.Light
            };
            ItemWeaponBlueprint item5Blueprint = new ItemWeaponBlueprint
            {
                Id               = 5,
                Name             = "item5",
                ShortDescription = "Fifth item (weapon)",
                Description      = "The fifth item (weapon) has been left here.",
                Type             = WeaponTypes.Sword1H,
                DiceCount        = 5,
                DiceValue        = 40,
                DamageType       = SchoolTypes.Physical,
                WearLocation     = WearLocations.Wield
            };

            //
            ServerOptions.CorpseBlueprint = new ItemCorpseBlueprint();

            // Add dummy mobs and items to allow impersonate :)
            IRoom templeOfMota = DependencyContainer.Instance.GetInstance <IWorld>().Rooms.FirstOrDefault(x => x.Name.ToLower() == "the temple of mota");
            IRoom templeSquare = DependencyContainer.Instance.GetInstance <IWorld>().Rooms.FirstOrDefault(x => x.Name.ToLower() == "the temple square");

            //ICharacter mob1 = DependencyContainer.Instance.GetInstance<IWorld>().AddCharacter(Guid.NewGuid(), "mob1", Repository.ClassManager["Mage"], Repository.RaceManager["Troll"], Sex.Male, templeOfMota); // playable
            ICharacter mob2 = DependencyContainer.Instance.GetInstance <IWorld>().AddCharacter(Guid.NewGuid(), mob2Blueprint, templeOfMota);
            ICharacter mob3 = DependencyContainer.Instance.GetInstance <IWorld>().AddCharacter(Guid.NewGuid(), mob3Blueprint, templeSquare);
            ICharacter mob4 = DependencyContainer.Instance.GetInstance <IWorld>().AddCharacter(Guid.NewGuid(), mob4Blueprint, templeSquare);
            ICharacter mob5 = DependencyContainer.Instance.GetInstance <IWorld>().AddCharacter(Guid.NewGuid(), mob5Blueprint, templeSquare);

            IItemContainer item1     = DependencyContainer.Instance.GetInstance <IWorld>().AddItemContainer(Guid.NewGuid(), item1Blueprint, templeOfMota);
            IItemContainer item1Dup1 = DependencyContainer.Instance.GetInstance <IWorld>().AddItemContainer(Guid.NewGuid(), item1Blueprint, templeOfMota);
            IItemWeapon    item2     = DependencyContainer.Instance.GetInstance <IWorld>().AddItemWeapon(Guid.NewGuid(), item2Blueprint, mob2);
            IItemArmor     item3     = DependencyContainer.Instance.GetInstance <IWorld>().AddItemArmor(Guid.NewGuid(), item3Blueprint, item1Dup1);
            //IItemLight item4 = DependencyContainer.Instance.GetInstance<IWorld>().AddItemLight(Guid.NewGuid(), item4Blueprint, mob1);
            //IItemWeapon item5 = DependencyContainer.Instance.GetInstance<IWorld>().AddItemWeapon(Guid.NewGuid(), item5Blueprint, mob1);
            //IItemContainer item1Dup2 = DependencyContainer.Instance.GetInstance<IWorld>().AddItemContainer(Guid.NewGuid(), item1Blueprint, mob1);
            IItemArmor item3Dup1 = DependencyContainer.Instance.GetInstance <IWorld>().AddItemArmor(Guid.NewGuid(), item3Blueprint, mob3);
            IItemLight item4Dup1 = DependencyContainer.Instance.GetInstance <IWorld>().AddItemLight(Guid.NewGuid(), item4Blueprint, mob4);

            // Equip weapon on mob2
            mob2.Equipments.FirstOrDefault(x => x.Slot == EquipmentSlots.Wield).Item = item2;
            item2.ChangeContainer(null);
            item2.ChangeEquipedBy(mob2);
        }
Exemple #10
0
 public void AddCharacterBlueprint(CharacterBlueprint blueprint)
 {
     throw new NotImplementedException();
 }
Exemple #11
0
 public ICharacter AddCharacter(Guid guid, CharacterBlueprint blueprint, IRoom room)
 {
     throw new NotImplementedException();
 }
Exemple #12
0
 public void SelectCharacterToBuild(CharacterBlueprint character)
 {
     characterToBuild = character;
 }
    private void CreatePlayer(int id, CharacterBlueprint c)
    {
        LogicEntity e = Contexts.sharedInstance.logic.CreateEntity();

        //Add the logic
        e.AddPlayerID(id);

        e.AddPosition(
            new FixedVector2(0, 0)
            );

        e.AddRotation(0);
        e.AddScale(
            new FixedVector2(
                CharacterBlueprint.scale,
                CharacterBlueprint.scale)
            );

        e.AddVelocity(
            new FixedVector2(0, 0)
            );

        e.AddAcceleration(
            new FixedVector2(0, 0)
            );

        e.isMovable = true;
        e.AddLastPosition(e.position.value);
        e.AddLastVelocity(e.velocity.value);

        //Movement
        e.AddCurrentMovementX(0, 0, 0);
        e.AddGroundMovement(c.groundSpeed, c.groundAcceleration);
        e.AddAirMovement(c.airSpeed, c.airAcceleration);
        e.AddDashMovement(c.dashSpeed, c.dashAcceleration, c.dashLength);
        e.AddStunMovement(0, FixedMath.Create(2));
        e.AddWallRideMovement(
            c.maxSlideSpeed,
            c.fastSlideFactor,
            c.innerJump,
            c.neutralJump,
            c.outerJump,
            //acceleration
            FixedMath.Create(2, 10),
            //walljump length
            FixedMath.Create(25, 100),
            //stick time
            FixedMath.Create(5, 100)

            );

        e.AddDirection(1);

        //Jump
        e.AddTimeToApex(c.timeToJumpApex);
        e.AddMinJump(c.minJump);          // 1.5
        e.AddMaxJump(c.maxJump);

        e.AddJumpsAllowed(c.jumpsAllowed);
        e.AddJumpsCompleted(0);
        e.AddFastFallFactor(c.fastFallFactor);
        e.AddTerminalVelocity(c.terminalVelocity);
        e.AddFastFallTerminalVelocity(c.terminalVelocityFastFall);
        e.AddBounceHeight(c.bounceHeight);
        e.AddStunTime(FixedMath.Hundredth * 2);

        e.AddReflectionDampening(c.reflectionDampPlayer.x, c.reflectionDampPlayer.y);

        e.AddCollider(new Determinism.BoxCollider(e.position.value, c.playerColOffsetPosition * CharacterBlueprint.scale, c.playerColScale * CharacterBlueprint.scale));
        e.AddOnRayCastCollision(new CommandInput.PlayerRayCastCollisionCommand(e.id.value));
        e.AddOnTriggerEnter(new OnTriggerEnterCommand(e.id.value));

        e.collider.value.tag  = Tag.PLAYER;
        e.collider.value.mask = (Mask)(1 << (id + 1));

        e.collider.value.check =
            e.collider.value.check.AddFlags(Mask.DEFAULT, Mask.P1, Mask.P2, Mask.P3, Mask.P4, Mask.P5, Mask.P6, Mask.P7, Mask.P8);

        e.collider.value.check =
            e.collider.value.check.RemoveFlag(e.collider.value.mask);

        e.AddPusher(new List <Passenger> ());
        e.isHitable = true;

        e.AddWeight(c.weightFactor);

        e.AddHat(CreateHat(id, e.id.value, c));
        e.isRespawn = true;


        var view = Object.Instantiate(c.player).GetComponent <IView>();

        view.Link(e, Contexts.sharedInstance.logic);
    }
    private int CreateHat(int id, int ownerID, CharacterBlueprint c)
    {
        LogicEntity e = Contexts.sharedInstance.logic.CreateEntity();

        e.AddPosition(
            new FixedVector2(0, 0)
            );

        e.AddRotation(0);
        e.AddLastRotation(0);
        e.AddScale(new FixedVector2(
                       CharacterBlueprint.scale,
                       CharacterBlueprint.scale)
                   );

        e.AddVelocity(
            new FixedVector2(0, 0)
            );

        e.AddAcceleration(
            new FixedVector2(0, 0)
            );

        e.isMovable = true;
        e.AddLastPosition(e.position.value);
        e.AddLastVelocity(e.velocity.value);

        //Movement
        e.AddDirection(1);

        //Follow
        e.isAttached = true;
        e.AddFollowPoint(ownerID, c.followSpeed, c.followPoint, c.pickUpRadius, c.maxRotation);

        //gravity is 50 * greater than in game
        e.AddGravity(c.gravity * 50);

        e.AddFriction(c.normalFriction, c.dangerousFriction);
        e.AddDrag(c.normalDrag, c.dangerousDrag);


        //* 50 / 10 from original amt
        e.AddThrowMovement(c.throwPower * 5, 0);

        //Throw
        e.AddKnockBack(c.blowBack);
        e.AddStunTime(c.stunTime);

        e.AddReflectionDampening(c.reflectionDampHat.x, c.reflectionDampHat.y);

        //collision
        e.AddCollider(new Determinism.BoxCollider(e.position.value, c.hatColOffsetPosition * CharacterBlueprint.scale, c.hatColScale * CharacterBlueprint.scale));
        e.AddOnRayCastCollision(new CommandInput.HatRayCastCollisionCommand(e.id.value));

        e.collider.value.tag  = Tag.HAT;
        e.collider.value.mask = (Mask)(1 << (id + 1));

        e.collider.value.isTrigger = true;

        e.collider.value.check =
            e.collider.value.check.AddFlags(Mask.DEFAULT, Mask.P1, Mask.P2, Mask.P3, Mask.P4, Mask.P5, Mask.P6, Mask.P7, Mask.P8);

        e.collider.value.check =
            e.collider.value.check.RemoveFlag(e.collider.value.mask);

        e.isHitable   = true;
        e.isPusheable = true;
        e.AddWeight(c.weightFactor);

        var view = Object.Instantiate(c.hat).GetComponent <IView>();

        view.Link(e, Contexts.sharedInstance.logic);

        return(e.id.value);
    }
Exemple #15
0
 public Quest(QuestBlueprint blueprint, ICharacter character, ICharacter giver)
 {
     _character  = character;
     Blueprint   = blueprint;
     Giver       = giver;
     _objectives = new List <QuestObjectiveBase>();
     if (Blueprint.ItemObjectives != null)
     {
         foreach (QuestItemObjectiveBlueprint itemObjective in Blueprint.ItemObjectives)
         {
             if (DependencyContainer.Instance.GetInstance <IWorld>().GetItemBlueprint(itemObjective.ItemBlueprintId) is ItemQuestBlueprint itemBlueprint)
             {
                 _objectives.Add(new ItemQuestObjective
                 {
                     Blueprint = itemBlueprint,
                     Count     = character.Content.Where(x => x.Blueprint != null).Count(x => x.Blueprint.Id == itemObjective.ItemBlueprintId), // should always be 0
                     Total     = itemObjective.Count
                 });
             }
             else
             {
                 Log.Default.WriteLine(LogLevels.Warning, $"Loot objective {itemObjective.ItemBlueprintId} doesn't exist (or is not quest item) for quest {blueprint.Id}");
             }
         }
     }
     if (Blueprint.KillObjectives != null)
     {
         foreach (QuestKillObjectiveBlueprint killObjective in Blueprint.KillObjectives)
         {
             CharacterBlueprint characterBlueprint = DependencyContainer.Instance.GetInstance <IWorld>().GetCharacterBlueprint(killObjective.CharacterBlueprintId);
             if (characterBlueprint != null)
             {
                 _objectives.Add(new KillQuestObjective
                 {
                     Blueprint = characterBlueprint,
                     Count     = 0,
                     Total     = killObjective.Count
                 });
             }
             else
             {
                 Log.Default.WriteLine(LogLevels.Warning, $"Kill objective {killObjective.CharacterBlueprintId} doesn't exist for quest {blueprint.Id}");
             }
         }
     }
     if (Blueprint.LocationObjectives != null)
     {
         foreach (QuestLocationObjectiveBlueprint locationObjective in Blueprint.LocationObjectives)
         {
             RoomBlueprint roomBlueprint = DependencyContainer.Instance.GetInstance <IWorld>().GetRoomBlueprint(locationObjective.RoomBlueprintId);
             if (roomBlueprint != null)
             {
                 _objectives.Add(new LocationQuestObjective
                 {
                     Blueprint = roomBlueprint,
                     Explored  = character.Room?.Blueprint?.Id == roomBlueprint.Id
                 });
             }
             else
             {
                 Log.Default.WriteLine(LogLevels.Warning, $"Location objective {locationObjective.RoomBlueprintId} doesn't exist for quest {blueprint.Id}");
             }
         }
     }
 }