Exemplo n.º 1
0
        protected override void Draw()
        {
            Camera.Update(null);

            // Clear to the default control background color.
            Color backColor = new Color(BackColor.R, BackColor.G, BackColor.B);

            GraphicsDevice.Clear(backColor);
            g.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend);

            PolygonEffect.View = Camera.View;
            g.GraphicsDevice.DepthStencilState = DepthStencilState.Default;
            g.GraphicsDevice.SamplerStates[0]  = SamplerState.PointClamp;
            g.GraphicsDevice.RasterizerState   = RasterizerState.CullCounterClockwise;

            foreach (Tile3D ActiveTile in ListTile3D)
            {
                PolygonEffect.Texture = ListTileSet[ActiveTile.TilesetIndex];
                PolygonEffect.CurrentTechnique.Passes[0].Apply();

                ActiveTile.Draw(g.GraphicsDevice);
            }

            g.End();
        }
Exemplo n.º 2
0
        public void Draw(CustomSpriteBatch g)
        {
            PolygonEffect.View = Camera.View;
            g.GraphicsDevice.DepthStencilState = DepthStencilState.Default;
            g.GraphicsDevice.SamplerStates[0]  = SamplerState.PointClamp;
            g.GraphicsDevice.RasterizerState   = RasterizerState.CullCounterClockwise;

            foreach (KeyValuePair <Texture2D, List <Tile3D> > ActiveTileSet in DicTile3D)
            {
                PolygonEffect.Texture = ActiveTileSet.Key;
                PolygonEffect.CurrentTechnique.Passes[0].Apply();

                foreach (Tile3D ActiveTile in ActiveTileSet.Value)
                {
                    ActiveTile.Draw(g.GraphicsDevice);
                }
            }

            PolygonEffect.Texture = sprCursor;
            PolygonEffect.CurrentTechnique.Passes[0].Apply();

            Cursor.Draw(g.GraphicsDevice);

            g.End();
            GameScreen.GraphicsDevice.DepthStencilState = DepthStencilState.Default;

            for (int P = 0; P < Map.ListPlayer.Count; P++)
            {
                //If the selected unit have the order to move, draw the possible positions it can go to.
                for (int U = 0; U < Map.ListPlayer[P].ListSquad.Count; U++)
                {//If it's dead, don't draw it unless it's an event unit.
                    if ((Map.ListPlayer[P].ListSquad[U].CurrentLeader == null && !Map.ListPlayer[P].ListSquad[U].IsEventSquad) || Map.ListPlayer[P].ListSquad[U].IsDead)
                    {
                        continue;
                    }

                    Color UnitColor;
                    if (Constants.UnitRepresentationState == Constants.UnitRepresentationStates.Colored)
                    {
                        UnitColor = Map.ListPlayer[P].Color;
                    }
                    else
                    {
                        UnitColor = Color.White;
                    }

                    Map.ListPlayer[P].ListSquad[U].Unit3D.SetViewMatrix(Camera.View);

                    Map.ListPlayer[P].ListSquad[U].Unit3D.SetPosition(
                        -Map.MapSize.X / 2 + 0.5f + Map.ListPlayer[P].ListSquad[U].Position.X,
                        Radius,
                        -Map.MapSize.Y / 2 + 0.5f + Map.ListPlayer[P].ListSquad[U].Y);

                    Map.ListPlayer[P].ListSquad[U].Unit3D.Draw(GameScreen.GraphicsDevice);
                }
            }
            g.Begin();
        }
Exemplo n.º 3
0
 public void ActivateTile(Point mousePosition)
 {
     ActiveTile = GetTileByCursorPosition(mousePosition);
     if (ActiveTile != null)
     {
         ActiveTile.State = TileState.Dragged;
         ActiveTile.DockToNode(null);
     }
 }
Exemplo n.º 4
0
    public void DestroyChild()
    {
        if (Child == null)
        {
            //          Debug.Log("Destroy not existing child, this should never happen");
        }
        else
        {
//            Debug.Log("Destroy Child at (" + X + "," + Y + ")");
            WorldController.Instance.RemoveTile(Child);
            Child = null;
        }
    }
Exemplo n.º 5
0
    public void CreateChild()
    {
//        Debug.Log("Try to create Child at (" + X + "," + Y + ")");
        if (Child != null)
        {
            return;
        }
        else
        {
//            Debug.Log("Created child at (" + X + "," + Y + ")");
            Child = new ActiveTile(this, X, Y);
            WorldController.Instance.RegisterTile(Child);
        }
    }
Exemplo n.º 6
0
    // Remove an active tile from screen, internally and visually
    public void RemoveTile(ActiveTile atile)
    {
        activetiles.Remove(atile);
        Destroy(atile.Sprite.GetComponent <BoxCollider>());
        Rigidbody rb  = atile.Sprite.GetComponent <Rigidbody>();
        Vector3   vel = new Vector3(-(5 - atile.X), -(5 - atile.Y), 20f);

        rb.velocity = new Vector3(-(5 - atile.X) / (1 + Mathf.Pow((5 - atile.X), 2)) * 15f, -(5 - atile.Y) / (1 + Mathf.Pow((5 - atile.Y), 2)) * 15f, 20f);
        rb.rotation = Quaternion.Euler(atile.X * 10, atile.Y * 10, 0);
        sprites.Add(atile.Sprite);
        //    Destroy(atile.Sprite);
        //    GameObject corpse = (GameObject)Instantiate(ATiles[0], new Vector3(atile.X, atile.Y, .1f), Quaternion.identity);
        //    corpse.GetComponent<Rigidbody>().AddForce(new Vector3(10, 10, 10));
    }
Exemplo n.º 7
0
        public void Draw(CustomSpriteBatch g, int LayerIndex, bool IsSubLayer, MovementAlgorithmTile[,] ArrayTerrain)
        {
            PolygonEffect.View = Camera.View;
            g.GraphicsDevice.DepthStencilState = DepthStencilState.Default;
            g.GraphicsDevice.SamplerStates[0]  = SamplerState.PointClamp;
            g.GraphicsDevice.RasterizerState   = RasterizerState.CullCounterClockwise;

            foreach (KeyValuePair <Texture2D, List <Tile3D> > ActiveTileSet in DicTile3D)
            {
                PolygonEffect.Texture = ActiveTileSet.Key;
                PolygonEffect.CurrentTechnique.Passes[0].Apply();

                foreach (Tile3D ActiveTile in ActiveTileSet.Value)
                {
                    ActiveTile.Draw(g.GraphicsDevice);
                }
            }

            PolygonEffect.Texture = sprCursor;
            PolygonEffect.CurrentTechnique.Passes[0].Apply();

            Cursor.Draw(g.GraphicsDevice);

            g.End();
            GameScreen.GraphicsDevice.DepthStencilState = DepthStencilState.Default;

            for (int P = 0; P < Map.ListPlayer.Count; P++)
            {
                Map.ListPlayer[P].GamePiece.Unit3D.SetViewMatrix(Camera.View);

                Map.ListPlayer[P].GamePiece.Unit3D.SetPosition(
                    -Map.MapSize.X / 2 + 0.5f + Map.ListPlayer[P].GamePiece.Position.X,
                    Radius,
                    -Map.MapSize.Y / 2 + 0.5f + Map.ListPlayer[P].GamePiece.Position.Y);

                Map.ListPlayer[P].GamePiece.Unit3D.Draw(GameScreen.GraphicsDevice);
            }
            g.Begin();
        }
Exemplo n.º 8
0
 public void DropTile(Point mousePosition)
 {
     ActiveTile.DockToNode(ModelRef.Grid.ActiveNode);
     ActiveTile.State = TileState.Normal;
     ActiveTile       = null;
 }
Exemplo n.º 9
0
 // Register tile to the ActiveTiles list and create the sprite
 public void RegisterTile(ActiveTile atile)
 {
     atile.Sprite = (GameObject)Instantiate(ATiles[0], new Vector3(atile.X, atile.Y, 3f), Quaternion.identity);
     atile.Sprite.GetComponent <Rigidbody>().AddForce(0, 0, -1000f);
     activetiles.Add(atile);
 }
Exemplo n.º 10
0
    private void SwitchToBattleStateProcess()
    {
        // Pause keepers
        foreach (PawnInstance pi in allKeepersList)
        {
            bool mustBeDisabled = false;
            for (int i = 0; i < currentFighters.Length && i < 3; i++)
            {
                if (pi == currentFighters[i])
                {
                    mustBeDisabled = true;
                }
            }

            if (mustBeDisabled)
            {
                pi.GetComponent <NavMeshAgent>().enabled = false;
            }
            else
            {
                NavMeshAgent currentAgent = pi.GetComponent <NavMeshAgent>();
                if (currentAgent != null && currentAgent.isActiveAndEnabled)
                {
                    currentAgent.Stop();
                    pausedAgents.Add(currentAgent);
                    pi.transform.GetChild(0).gameObject.SetActive(false);
                    disabledModels.Add(pi.transform.GetChild(0).gameObject);
                    if (pi.GetComponent <GlowObjectCmd>() != null)
                    {
                        GlowController.UnregisterObject(pi.GetComponent <GlowObjectCmd>());
                        unregisteredGlows.Add(pi.GetComponent <GlowObjectCmd>());
                    }
                }
            }

            pi.GetComponent <Keeper>().ShowSelectedPanelUI(false);
            ui.ClearActionPanel();
            ui.HideInventoryPanels();
        }

        // Pause NPCs
        // If needed, we should register all PNJ on tiles in TileManager so we can handle AI behaviours when the game paused
        // For now we'll only deal with the prisoner
        if (currentFighters[currentFighters.Length - 1].GetComponent <Prisoner>() != null)
        {
            NavMeshAgent prisonerAgent = currentFighters[currentFighters.Length - 1].GetComponent <NavMeshAgent>();
            if (prisonerAgent != null && prisonerAgent.isActiveAndEnabled)
            {
                prisonerAgent.enabled = false;
            }
        }
        else
        {
            if (prisonerInstance != null)
            {
                NavMeshAgent prisonerAgent = prisonerInstance.GetComponent <NavMeshAgent>();
                if (prisonerAgent != null && prisonerAgent.isActiveAndEnabled)
                {
                    prisonerAgent.Stop();
                    pausedAgents.Add(prisonerAgent);
                }
            }
        }

        // Pause monsters
        foreach (Tile tile in tileManagerReference.MonstersOnTile.Keys)
        {
            if (tile != cameraManagerReference.ActiveTile)
            {
                List <PawnInstance> monsterList = tileManagerReference.MonstersOnTile[tile];
                foreach (PawnInstance pi in monsterList)
                {
                    NavMeshAgent currentAgent = pi.GetComponent <NavMeshAgent>();
                    if (currentAgent != null && currentAgent.isActiveAndEnabled)
                    {
                        currentAgent.Stop();
                        pausedAgents.Add(currentAgent);
                    }
                }
            }
            else
            {
                List <PawnInstance> monsterList = tileManagerReference.MonstersOnTile[tile];
                foreach (PawnInstance pi in monsterList)
                {
                    NavMeshAgent currentAgent = pi.GetComponent <NavMeshAgent>();
                    if (currentAgent != null)
                    {
                        pi.GetComponent <AnimatedPawn>().WasAgentActiveBeforeBattle = currentAgent.isActiveAndEnabled;
                        if (currentAgent.isActiveAndEnabled)
                        {
                            currentAgent.enabled = false;
                        }
                    }
                    if (pi.GetComponent <GlowObjectCmd>() != null)
                    {
                        GlowController.RegisterObject(pi.GetComponent <GlowObjectCmd>());
                    }

                    if (pi.GetComponentInChildren <AggroBehaviour>() != null)
                    {
                        pi.GetComponentInChildren <AggroBehaviour>().gameObject.SetActive(false);
                    }
                }
            }
        }

        // Mask tile portals
        Transform tilePortals = currentFighters[0].CurrentTile.transform.GetChild(0).GetChild((int)TilePrefabChildren.PortalTriggers);

        for (int i = 0; i < tilePortals.childCount; i++)
        {
            if (tilePortals.GetChild(i).gameObject.activeSelf)
            {
                tilePortalsDisabled.Add(tilePortals.GetChild(i).gameObject);
                tilePortals.GetChild(i).gameObject.SetActive(false);
            }
        }

        // Mask quest reminder button
        gameScreens.transform.GetChild(0).GetChild((int)IngameScreensEnum.QuestReminderButton).gameObject.SetActive(false);

        Transform tileModel = ActiveTile.transform.GetChild(0).GetChild((int)TilePrefabChildren.Model);

        for (int i = 0; i < tileModel.childCount; i++)
        {
            if (tileModel.GetChild(i).name.Equals("Center"))
            {
                tileModel.GetChild(i).gameObject.SetActive(false);
                disabledModels.Add(tileModel.GetChild(i).gameObject);
            }
        }

        PawnInstance[] toDisable = ActiveTile.GetComponentsInChildren <PawnInstance>();
        foreach (PawnInstance pi in toDisable)
        {
            if (pi.GetComponent <Monster>() == null)
            {
                pi.gameObject.SetActive(false);
                disabledModels.Add(pi.gameObject);
            }
        }

        LootInstance[] lootToDisable = ActiveTile.GetComponentsInChildren <LootInstance>();
        foreach (LootInstance li in lootToDisable)
        {
            li.gameObject.SetActive(false);
            disabledModels.Add(li.gameObject);
        }

        // Make escortable disappear
        if (TileManager.Instance.EscortablesOnTile.ContainsKey(ActiveTile))
        {
            foreach (PawnInstance pi in TileManager.Instance.EscortablesOnTile[ActiveTile])
            {
                pi.gameObject.SetActive(false);
                disabledModels.Add(pi.gameObject);
            }
        }

        // Hide item instance
        for (int i = 1; i < ActiveTile.transform.childCount; i++)
        {
            ItemInstance curItem = ActiveTile.transform.GetChild(i).GetComponentInChildren <ItemInstance>();
            if (curItem != null)
            {
                curItem.transform.parent.gameObject.SetActive(false);
                disabledModels.Add(curItem.transform.parent.gameObject);
            }
        }

        Ui.GoActionPanelQ.transform.parent.SetParent(Ui.transform);
    }