private void OmniB_Click(Button sender)
        {
            AKB.Active   = false;
            OmniB.Active = true;

            selectedSpawnPoint = null;

            foreach (PossibleSpawnPoint psp in possibleSpawnPoints)
            {
                psp.btn.Active = false;
                psp.btn.Enable = psp.text.Enable = (psp.sp.Faction.Name == "Omni");
            }
        }
        private void btn_Click(Button sender)
        {
            PossibleSpawnPoint sp = sender.UserData as PossibleSpawnPoint;

            selectedSpawnPoint = sp;

            foreach (PossibleSpawnPoint psp in possibleSpawnPoints)
            {
                psp.btn.Active = false;
            }

            selectedSpawnPoint.btn.Active = true;
        }
        private void AKB_Click(Button sender)
        {
            AKB.Active   = true;
            OmniB.Active = false;

            selectedSpawnPoint = null;

            Rect   screenMapRect = spawnPoints.GetScreenRectangle();
            Bounds initialBounds = Map.Instance.InitialCollisionBounds;
            Rect   mapRect       = new Rect(initialBounds.Minimum.ToVec2(), initialBounds.Maximum.ToVec2());

            foreach (PossibleSpawnPoint psp in possibleSpawnPoints)
            {
                psp.btn.Active = false;
                psp.btn.Enable = psp.text.Enable = (psp.sp.Faction.Name == "AssaultKnights");
            }
        }
예제 #4
0
        public bool FindSpawnPointForPawn(PawnBase pawn, out SpawnPoint spawnPoint)
        {
            List <SpawnPoint> possibPoints = new List <SpawnPoint>();

            foreach (SpawnPoint PossibleSpawnPoint in spawnPoints)
            {
                if (PossibleSpawnPoint.CanPawnSpawnAtPoint(pawn))
                {
                    possibPoints.Add(PossibleSpawnPoint);
                }
            }

            if (possibPoints.Count == 0)
            {
                Debug.LogError($"Failed to find spawnpoint for '{pawn.ToString()}'");
                spawnPoint = null;
                return(false);
            }

            SpawnPoint smallPoint = null;

            foreach (var point in possibPoints)
            {
                if (smallPoint == null)
                {
                    smallPoint = point;
                    continue;
                }

                if (smallPoint.spawncount > point.spawncount)
                {
                    smallPoint = point;
                }
            }

            spawnPoint = smallPoint;

            return(true);
        }
        protected override void OnAttach()
        {
            if (GameMap.Instance.GameType != GameMap.GameTypes.AssaultKnights)
            {
                return;
            }

            base.OnAttach();

            if (EntitySystemWorld.Instance.IsClientOnly())//&& !EntitySystemWorld.Instance.IsEditor())
            {
                GameNetworkClient.Instance.CustomMessagesService.ReceiveMessage += new CustomMessagesClientNetworkService.ReceiveMessageDelegate(Client_CustomMessagesService_ReceiveMessage);
            }

            window = ControlDeclarationManager.Instance.CreateControl("Gui\\PlayerSpawnWindow.gui");
            Controls.Add(window);

            spawnPoints = window.Controls["spawnPoints"];

            if (Map.Instance == null)
            {
                return;
            }

            //Need to Get Control Manager layers from map
            //Get Basemap value

            //layers
            //{
            //    item
            //    {
            //        name = base
            //        baseMap = "Assault Knights\\AKMaps\\AriFlats\\Textures\\flatsCM.png"
            //        baseScale = 10000
            //        detailMap = "Assault Knights\\Maps\\Map Textures\\Terrain\\DetailTextures\\64d0b218.png"
            //        detailScale = 20
            //        detailNormalMap = "Assault Knights\\Maps\\Map Textures\\Terrain\\DetailTextures\\cracked_ground_normal.tga_converted.dds"
            //    }

            //Incin -- better way each file is Assault Knights\\AKMaps\\"MapName"\\Textures\\overview.png
            //each file is 1024 x 1024 .png file
            string  mapvirtualpath = Map.Instance.GetVirtualFileDirectory().ToString();
            Texture backtexture    = TextureManager.Instance.Load(mapvirtualpath + "\\Textures\\overview.png");

            if (backtexture != null)
            {
                spawnPoints.BackTexture = backtexture;
            }
            else
            {
                Log.Info("Invalid Path or filename of spawnPoints.BackTexture window: {0}, verify location of file or file exists!", backtexture);
            }

            Rect   screenMapRect = spawnPoints.GetScreenRectangle();
            Bounds initialBounds = Map.Instance.InitialCollisionBounds;
            Rect   mapRect       = new Rect(initialBounds.Minimum.ToVec2(), initialBounds.Maximum.ToVec2());

            foreach (Entity entity in Map.Instance.Children)
            {
                if (GameMap.Instance.GameType == GameMap.GameTypes.AssaultKnights)
                {
                    SpawnPoint sp = entity as SpawnPoint;
                    if (sp != null)
                    {
                        btn = ControlDeclarationManager.Instance.CreateControl(
                            "Gui\\Controls\\AKDefaultBaseButton.gui") as Button;

                        txt          = new TextBox();
                        txt.AutoSize = true;
                        txt.Text     = sp.Text;

                        PossibleSpawnPoint psp = new PossibleSpawnPoint();
                        psp.btn      = btn;
                        psp.sp       = sp;
                        psp.spid     = sp.SpawnID.ToString(); //set spawnid of spawnpoint -- needed network passing
                        psp.text     = txt;
                        btn.UserData = psp;
                        btn.Click   += new Button.ClickDelegate(btn_Click);
                        float x = 0.5f + sp.Position.X / mapRect.Size.X;
                        float y = 0.5f + sp.Position.Y / mapRect.Size.Y;

                        btn.Position = new ScaleValue(ScaleType.Parent, new Vec2(x, y));
                        txt.Position = new ScaleValue(ScaleType.Parent, new Vec2(x + 0.05f, y));
                        spawnPoints.Controls.Add(btn);
                        spawnPoints.Controls.Add(txt);
                        possibleSpawnPoints.Add(psp);
                    }
                }
            }

            done        = window.Controls["Done"] as Button;
            done.Click += new Button.ClickDelegate(done_Click);

            suicide        = window.Controls["Sucide"] as Button;
            suicide.Click += new Button.ClickDelegate(suicide_Click);
            AKB            = window.Controls["AK"] as Button;
            AKB.Click     += new Button.ClickDelegate(AKB_Click);
            OmniB          = window.Controls["Omni"] as Button;
            OmniB.Click   += new Button.ClickDelegate(OmniB_Click);

            AKB.Active = true;
        }
        protected override void OnAttach()
        {
            if (GameMap.Instance.GameType != GameMap.GameTypes.AssaultKnights)
            {
                return;
            }

            base.OnAttach();

            if (EntitySystemWorld.Instance.IsClientOnly())//&& !EntitySystemWorld.Instance.IsEditor())
            {
                GameNetworkClient.Instance.CustomMessagesService.ReceiveMessage += new CustomMessagesClientNetworkService.ReceiveMessageDelegate(Client_CustomMessagesService_ReceiveMessage);
            }

            window = ControlDeclarationManager.Instance.CreateControl("Gui\\PlayerSpawnWindow.gui");
            Controls.Add(window);

            spawnPoints = window.Controls["spawnPoints"];

            if (Map.Instance == null)
                return;

            //Need to Get Control Manager layers from map
            //Get Basemap value

            //layers
            //{
            //    item
            //    {
            //        name = base
            //        baseMap = "Assault Knights\\AKMaps\\AriFlats\\Textures\\flatsCM.png"
            //        baseScale = 10000
            //        detailMap = "Assault Knights\\Maps\\Map Textures\\Terrain\\DetailTextures\\64d0b218.png"
            //        detailScale = 20
            //        detailNormalMap = "Assault Knights\\Maps\\Map Textures\\Terrain\\DetailTextures\\cracked_ground_normal.tga_converted.dds"
            //    }

            //Incin -- better way each file is Assault Knights\\AKMaps\\"MapName"\\Textures\\overview.png
            //each file is 1024 x 1024 .png file
            string mapvirtualpath = Map.Instance.GetVirtualFileDirectory().ToString();
            Texture backtexture = TextureManager.Instance.Load(mapvirtualpath + "\\Textures\\overview.png");

            if (backtexture != null)
                spawnPoints.BackTexture = backtexture;
            else
                Log.Info("Invalid Path or filename of spawnPoints.BackTexture window: {0}, verify location of file or file exists!", backtexture);

            Rect screenMapRect = spawnPoints.GetScreenRectangle();
            Bounds initialBounds = Map.Instance.InitialCollisionBounds;
            Rect mapRect = new Rect(initialBounds.Minimum.ToVec2(), initialBounds.Maximum.ToVec2());

            foreach (Entity entity in Map.Instance.Children)
            {
                if (GameMap.Instance.GameType == GameMap.GameTypes.AssaultKnights)
                {
                    SpawnPoint sp = entity as SpawnPoint;
                    if (sp != null)
                    {
                        btn = ControlDeclarationManager.Instance.CreateControl(
                            "Gui\\Controls\\AKDefaultBaseButton.gui") as Button;

                        txt = new TextBox();
                        txt.AutoSize = true;
                        txt.Text = sp.Text;

                        PossibleSpawnPoint psp = new PossibleSpawnPoint();
                        psp.btn = btn;
                        psp.sp = sp;
                        psp.spid = sp.SpawnID.ToString(); //set spawnid of spawnpoint -- needed network passing
                        psp.text = txt;
                        btn.UserData = psp;
                        btn.Click += new Button.ClickDelegate(btn_Click);
                        float x = 0.5f + sp.Position.X / mapRect.Size.X;
                        float y = 0.5f + sp.Position.Y / mapRect.Size.Y;

                        btn.Position = new ScaleValue(ScaleType.Parent, new Vec2(x, y));
                        txt.Position = new ScaleValue(ScaleType.Parent, new Vec2(x + 0.05f, y));
                        spawnPoints.Controls.Add(btn);
                        spawnPoints.Controls.Add(txt);
                        possibleSpawnPoints.Add(psp);
                    }
                }
            }

            done = window.Controls["Done"] as Button;
            done.Click += new Button.ClickDelegate(done_Click);

            suicide = window.Controls["Sucide"] as Button;
            suicide.Click += new Button.ClickDelegate(suicide_Click);
            AKB = window.Controls["AK"] as Button;
            AKB.Click += new Button.ClickDelegate(AKB_Click);
            OmniB = window.Controls["Omni"] as Button;
            OmniB.Click += new Button.ClickDelegate(OmniB_Click);

            AKB.Active = true;
        }
        private void OmniB_Click(Button sender)
        {
            AKB.Active = false;
            OmniB.Active = true;

            selectedSpawnPoint = null;

            foreach (PossibleSpawnPoint psp in possibleSpawnPoints)
            {
                psp.btn.Active = false;
                psp.btn.Enable = psp.text.Enable = (psp.sp.Faction.Name == "Omni");
            }
        }
        private void AKB_Click(Button sender)
        {
            AKB.Active = true;
            OmniB.Active = false;

            selectedSpawnPoint = null;

            Rect screenMapRect = spawnPoints.GetScreenRectangle();
            Bounds initialBounds = Map.Instance.InitialCollisionBounds;
            Rect mapRect = new Rect(initialBounds.Minimum.ToVec2(), initialBounds.Maximum.ToVec2());

            foreach (PossibleSpawnPoint psp in possibleSpawnPoints)
            {
                psp.btn.Active = false;
                psp.btn.Enable = psp.text.Enable = (psp.sp.Faction.Name == "AssaultKnights");
            }
        }
        private void btn_Click(Button sender)
        {
            PossibleSpawnPoint sp = sender.UserData as PossibleSpawnPoint;
            selectedSpawnPoint = sp;

            foreach (PossibleSpawnPoint psp in possibleSpawnPoints)
                psp.btn.Active = false;

            selectedSpawnPoint.btn.Active = true;
        }