Inheritance: MonoBehaviour
Ejemplo n.º 1
0
    public void Init()
    {
        TextAsset Asset = Resources.Load <TextAsset>("CharaterStats");
        JSONNode  Node  = JSON.Parse(Asset.text);

        for (int i = 0; i < Node.Count; ++i)
        {
            Stat stat = new Stat()
            {
                HP           = float.Parse(Node[i]["HP"]),
                AttackRange  = float.Parse(Node[i]["AttackRange"]),
                AttackSpeed  = float.Parse(Node[i]["AttackSpeed"]),
                AttackDamage = float.Parse(Node[i]["AttackDamage"]),
                MoveSpeed    = float.Parse(Node[i]["MoveSpeed"]),
                RecoveryHP   = float.Parse(Node[i]["Recovery"])
            };
            InstanceHandler handler = new InstanceHandler()
            {
                Stat         = stat,
                Path         = Node[i]["Path"].Value,
                AgentDensity = float.Parse(Node[i]["AgentDensity"]),
                IdleState    = int.Parse(Node[i]["IdleState"]),
                AttackState  = int.Parse(Node[i]["AttackState"]),
                MoveState    = int.Parse(Node[i]["MoveState"]),
                DeathState   = int.Parse(Node[i]["DeathState"]),
                ChaseState   = int.Parse(Node[i]["ChaseState"]),
            };
            m_instanceHandlerDic.Add((ECharacters)i, handler);
        }
        m_mainCharacter = InstantiateCharacter(ECharacters.Main, new Vector2(0, -25f), 0) as PlayerCharacter;
    }
Ejemplo n.º 2
0
 private void OnInit()
 {
     Handler = new InstanceHandler(ObjType);
     foreach (System.Reflection.PropertyInfo pi in ObjType.GetProperties(System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.Public))
     {
         if (pi.CanWrite && pi.GetIndexParameters().Length == 0)
         {
             Properties.Add(new PropertyBinder(pi));
         }
     }
 }
Ejemplo n.º 3
0
        public async Task KeyPress(string guid, string keyCode)
        {
            Instance i = InstanceHandler.TryGetInstance(guid);

            if (i == null)
            {
                Clients.Caller.SendAsync("Log", "ERROR: Game instance not active!");
            }
            else
            {
                i.WriteChar((char)Convert.ToInt32(keyCode));
            }
        }
Ejemplo n.º 4
0
        public async Task Start(string guid)
        {
            User u = this.GetUser(guid);

            if (await this.InvalidUser(u))
            {
                return;
            }

            await Clients.Caller.SendAsync("Update", "Starting game...");


            InstanceHandler.NewInstance(Clients.Caller, Context.ConnectionId, guid);
        }
Ejemplo n.º 5
0
        public App()
        {
            if (AppDomain.CurrentDomain.FriendlyName.EndsWith(".vshost.exe"))
            {
                return;
            }

            Application.Current.DispatcherUnhandledException += CurrentOnDispatcherUnhandledException;
            AppDomain.CurrentDomain.UnhandledException       += CurrentDomainOnUnhandledException;

            if (!InstanceHandler.Startup("ScriptPlayer-Instance", "ScriptPlayer-CommandLinePipe"))
            {
                Environment.Exit(0);
            }
        }
Ejemplo n.º 6
0
        public App()
        {
            DateTime start = DateTime.Now;

            if (AppDomain.CurrentDomain.FriendlyName.EndsWith(".vshost.exe"))
            {
                return;
            }

            Application.Current.DispatcherUnhandledException += CurrentOnDispatcherUnhandledException;
            AppDomain.CurrentDomain.UnhandledException       += CurrentDomainOnUnhandledException;

            if (!InstanceHandler.Startup("ScriptPlayer-Instance", "ScriptPlayer-CommandLinePipe"))
            {
                string debugMessage = $"CLI ExecutionTime = {(DateTime.Now - start).TotalSeconds:f3}s";

                Debug.WriteLine(debugMessage);
                Console.WriteLine(debugMessage);
                Environment.Exit(0);
            }
        }
Ejemplo n.º 7
0
 /// <summary>
 /// Called within Map Context.
 /// Sends initial packets
 /// </summary>
 private void OnLogin()
 {
     InstanceHandler.SendDungeonDifficulty(this);
     CharacterHandler.SendVerifyWorld(this);
     AccountDataHandler.SendAccountDataTimes(m_client);
     VoiceChatHandler.SendSystemStatus(this, VoiceSystemStatus.Disabled);
     // SMSG_GUILD_EVENT
     // SMSG_GUILD_BANK_LIST
     CharacterHandler.SendBindUpdate(this, BindLocation);
     TutorialHandler.SendTutorialFlags(this);
     SpellHandler.SendSpellsAndCooldowns(this);
     CharacterHandler.SendActionButtons(this);
     FactionHandler.SendFactionList(this);
     // SMSG_INIT_WORLD_STATES
     // SMSG_EQUIPMENT_SET_LIST
     AchievementHandler.SendAchievementData(this);
     // SMSG_EXPLORATION_EXPERIENCE
     CharacterHandler.SendTimeSpeed(this);
     TalentHandler.SendTalentGroupList(m_talents);
     AuraHandler.SendAllAuras(this);
     // SMSG_PET_GUIDS
 }
Ejemplo n.º 8
0
        /// <summary>
        /// This is called when an area trigger causes entering an instance
        /// </summary>
        public static bool EnterInstance(Character chr, MapTemplate mapTemplate, Vector3 targetPos)
        {
            if (!mapTemplate.IsInstance)
            {
                log.Error("Character {0} tried to enter \"{1}\" as Instance.", chr,
                          mapTemplate);
                return(false);
            }

            bool  isRaid = mapTemplate.Type == MapType.Raid;
            Group group  = chr.Group;

            if (isRaid && !chr.Role.IsStaff && !group.Flags.HasFlag(GroupFlags.Raid))
            {
                InstanceHandler.SendRequiresRaid(chr.Client, 0);
                return(false);
            }

            if (!mapTemplate.MayEnter(chr))
            {
                return(false);
            }
            chr.SendSystemMessage("Entering instance...");
            InstanceCollection instances = chr.Instances;
            BaseInstance       instance  = instances.GetActiveInstance(mapTemplate);

            if (instance == null)
            {
                if (mapTemplate.GetDifficulty(chr.GetInstanceDifficulty(isRaid)).BindingType == BindingType.Soft &&
                    !instances.HasFreeInstanceSlot && !chr.GodMode)
                {
                    MovementHandler.SendTransferFailure(chr.Client, mapTemplate.Id,
                                                        MapTransferError.TRANSFER_ABORT_TOO_MANY_INSTANCES);
                    return(false);
                }

                if (group != null)
                {
                    instance = group.GetActiveInstance(mapTemplate);
                    if (instance != null && !CheckFull(instance, chr))
                    {
                        return(false);
                    }
                }

                if (instance == null)
                {
                    instance = CreateInstance(chr, mapTemplate.InstanceTemplate,
                                              chr.GetInstanceDifficulty(isRaid));
                    if (instance == null)
                    {
                        log.Warn("Could not create Instance \"{0}\" for: {1}", mapTemplate,
                                 chr);
                        return(false);
                    }
                }
            }
            else if (!chr.GodMode)
            {
                if (!CheckFull(instance, chr))
                {
                    return(false);
                }
                if (isRaid)
                {
                    if (group == null)
                    {
                        MovementHandler.SendTransferFailure(chr.Client, instance.Id,
                                                            MapTransferError.TRANSFER_ABORT_NEED_GROUP);
                        return(false);
                    }

                    InstanceBinding binding1 =
                        group.InstanceLeaderCollection.GetBinding(mapTemplate.Id, BindingType.Hard);
                    InstanceBinding binding2 = instances.GetBinding(mapTemplate.Id, BindingType.Hard);
                    if (binding2 != null && binding1 != binding2)
                    {
                        MovementHandler.SendTransferFailure(chr.Client, instance.Id,
                                                            MapTransferError.TRANSFER_ABORT_NOT_FOUND);
                        return(false);
                    }
                }
            }

            instance.TeleportInside(chr, targetPos);
            return(true);
        }
Ejemplo n.º 9
0
 public MainWindow()
 {
     InitializeComponent();
     InstanceHandler =
         new InstanceHandler("C:\\Users\\Joshua\\Documents\\Minecraft Server-1.14.3\\Paper-1.14.4_latest.jar");
 }
Ejemplo n.º 10
0
        public override Task OnDisconnectedAsync(Exception exception)
        {
            InstanceHandler.TryRemoveInstance(Context.ConnectionId);

            return(base.OnDisconnectedAsync(exception));
        }
Ejemplo n.º 11
0
        private void OnInit()
        {
            Handler = new InstanceHandler(ObjType);
            foreach (System.Reflection.PropertyInfo pi in ObjType.GetProperties(System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.Public))
            {

                if (pi.CanWrite && pi.GetIndexParameters().Length == 0)
                    Properties.Add(new PropertyBinder(pi));
            }
        }
Ejemplo n.º 12
0
        /// <summary>
        /// This is called when an area trigger causes entering an instance
        /// </summary>
        public static bool EnterInstance(Character chr, MapTemplate mapTemplate, Vector3 targetPos)
        {
            if (!mapTemplate.IsInstance)
            {
                log.Error("Character {0} tried to enter \"{1}\" as Instance.", chr, mapTemplate);
                return(false);
            }

            var isRaid = (mapTemplate.Type == MapType.Raid);
            var group  = chr.Group;

            if (isRaid && !chr.Role.IsStaff && !group.Flags.HasFlag(GroupFlags.Raid))
            {
                InstanceHandler.SendRequiresRaid(chr.Client, 0);
                return(false);
            }

            if (!mapTemplate.MayEnter(chr))
            {
                return(false);
            }

            chr.SendSystemMessage("Entering instance...");

            // Find out if we've been here before
            var instances = chr.Instances;
            var instance  = instances.GetActiveInstance(mapTemplate);

            if (instance == null)
            {
                var difficulty = mapTemplate.GetDifficulty(chr.GetInstanceDifficulty(isRaid));

                // Check whether we were in too many normal dungeons recently
                if (difficulty.BindingType == BindingType.Soft && !instances.HasFreeInstanceSlot && !chr.GodMode)
                {
                    MovementHandler.SendTransferFailure(chr.Client, mapTemplate.Id, MapTransferError.TRANSFER_ABORT_TOO_MANY_INSTANCES);
                    return(false);
                }

                // Check whether we can join a group-owned instance
                if (group != null)
                {
                    instance = group.GetActiveInstance(mapTemplate);
                    if (instance != null)
                    {
                        if (!CheckFull(instance, chr))
                        {
                            return(false);
                        }
                    }
                }

                if (instance == null)
                {
                    // create new instance
                    instance = CreateInstance(chr, mapTemplate.InstanceTemplate, chr.GetInstanceDifficulty(isRaid));
                    if (instance == null)
                    {
                        log.Warn("Could not create Instance \"{0}\" for: {1}", mapTemplate, chr);
                        return(false);
                    }
                }
            }
            else if (!chr.GodMode)
            {
                if (!CheckFull(instance, chr))
                {
                    return(false);
                }

                // Check that the Raid member has the same instance as the leader
                if (isRaid)
                {
                    if (group == null)
                    {
                        MovementHandler.SendTransferFailure(chr.Client, instance.Id, MapTransferError.TRANSFER_ABORT_NEED_GROUP);
                        return(false);
                    }

                    var leaderRaid = group.InstanceLeaderCollection.GetBinding(mapTemplate.Id, BindingType.Hard);
                    var playerRaid = instances.GetBinding(mapTemplate.Id, BindingType.Hard);

                    if (playerRaid != null && leaderRaid != playerRaid)
                    {
                        // Player has a different instance than the leader
                        MovementHandler.SendTransferFailure(chr.Client, instance.Id, MapTransferError.TRANSFER_ABORT_NOT_FOUND);
                        return(false);
                    }
                }
            }

            instance.TeleportInside(chr, targetPos);
            return(true);
        }