Exemple #1
0
        protected override void OnChanged(Character character)
        {
            // Make sure the furniture's graphics are correct.
            GameObject     inventoryGo = objectGameObjectMap[character].transform.GetChild(0).gameObject;
            SpriteRenderer inventorySR = inventoryGo.GetComponent <SpriteRenderer>();

            // Important to set the characters SortOrder first.
            int charSortOrder = character.Animation.SetAndGetSortOrder();

            if (character.Inventory != null)
            {
                inventorySR = InventorySpriteController.SetSprite(inventoryGo, character.Inventory);
                inventorySR.sortingOrder = charSortOrder + 1;
            }
            else
            {
                inventorySR.sprite = null;
                if (inventoryGo.transform.childCount > 0)
                {
                    // Inventory should only ever have one child to destroy.
                    GameObject.Destroy(inventoryGo.transform.GetChild(0).gameObject);
                }
            }

            if (objectGameObjectMap.ContainsKey(character) == false)
            {
                UnityDebugger.Debugger.LogError("CharacterSpriteController", "OnCharacterChanged -- trying to change visuals for character not in our map.");
                return;
            }

            GameObject char_go = objectGameObjectMap[character];

            char_go.transform.position = new Vector3(character.X, character.Y, character.Z);
        }
Exemple #2
0
    public List <GameObject> HandleDragVisual(MouseController.DragParameters parameters, Transform parent)
    {
        List <GameObject> objects = new List <GameObject>();

        if (parameters.EndX != parameters.StartX)
        {
            // We should NEVER reach here, the disable dragging means that this should NEVER be true
            throw new ArgumentException("Parameters Start X/Y values should Equal End X/Y values, this is taken care by the DisableDragging = true property.");
        }

        Tile t = WorldController.Instance.World.GetTileAt(parameters.StartX, parameters.StartY, WorldController.Instance.CameraController.CurrentLayer);

        if (t != null)
        {
            // Show generic visuals
            GameObject go = new GameObject();
            go.transform.SetParent(parent);
            go.transform.position = new Vector3(parameters.StartX, parameters.StartY);

            if (t.Furniture == null && (t.Inventory == null || t.Inventory.Type == InventoryToBuild) && t.Type != TileType.Empty)
            {
                InventorySpriteController.SetSprite(go, CurrentInventory).color = Color.green; // = new Color(0.5f, 1f, 0.5f, 0.25f);
            }
            else
            {
                InventorySpriteController.SetSprite(go, CurrentInventory).color = Color.red; // new Color(1f, 0.5f, 0.5f, 0.25f);
            }

            objects.Add(go);
        }

        return(objects);
    }
        protected override void OnChanged(Character character)
        {
            // Make sure the furniture's graphics are correct.
            GameObject     inventoryGo = objectGameObjectMap[character].transform.GetChild(0).gameObject;
            SpriteRenderer inventorySR = inventoryGo.GetComponent <SpriteRenderer>();

            // Important to set the characters SortOrder first.
            int charSortOrder = character.Animation.SetAndGetSortOrder();

            if (character.Inventory != null)
            {
                inventorySR = InventorySpriteController.SetSprite(inventoryGo, character.Inventory);
                inventorySR.sortingOrder = charSortOrder + 1;
            }
            else
            {
                inventorySR.sprite = null;
                if (inventoryGo.transform.childCount > 0)
                {
                    // Inventory should only ever have one child to destroy.
                    GameObject.Destroy(inventoryGo.transform.GetChild(0).gameObject);
                }
            }

            GameObject char_go;

            if (objectGameObjectMap.TryGetValue(character, out char_go) == false)
            {
                UnityDebugger.Debugger.LogError("CharacterSpriteController", "OnCharacterChanged -- trying to change visuals for character not in our map.");
                return;
            }

            char_go.transform.position = new Vector3(character.X, character.Y, character.Z);

            if (character.IsSelected)
            {
                VisualPath path = char_go.GetComponentInChildren <VisualPath>();
                if (path == null)
                {
                    path = GameObject.Instantiate <VisualPath>(Resources.Load <VisualPath>("UI/VisualPath"), char_go.transform);
                }

                path.SetVisualPoints(character.Path);
            }
        }
        protected override void OnChanged(GameCharacter character)
        {
            // Make sure the furniture's graphics are correct.
            GameObject     inventoryGo = objectGameObjectMap[character].transform.GetChild(0).gameObject;
            SpriteRenderer inventorySR = inventoryGo.GetComponent <SpriteRenderer>();


            // Important to set the characters SortOrder first.
            int charSortOrder = character.Animation.SetAndGetSortOrder();

            if (character.Inventory != null)
            {
                inventorySR = InventorySpriteController.SetSprite(inventoryGo, character.Inventory);
                inventorySR.sortingOrder = charSortOrder + 1;
            }
            else
            {
                inventorySR.sprite = null;
                if (inventoryGo.transform.childCount > 0)
                {
                    // Inventory should only ever have one child to destroy.
                    GameObject.Destroy(inventoryGo.transform.GetChild(0).gameObject);
                }
            }

            if (objectGameObjectMap.ContainsKey(character) == false)
            {
                UnityDebugger.Debugger.LogError("CharacterSpriteController", "OnCharacterChanged -- trying to change visuals for character not in our map.");
                return;
            }

            GameObject char_go = objectGameObjectMap[character];

            char_go.transform.position = new Vector3(character.X, character.Y, character.Z);
            UpdatePosition(character.Tile, char_go);

            /* Debug.DrawLine(char_go.transform.position, Utils.TwoDToIso(character.Tile.Vector3), Color.red, 1);
             * Debug.DrawLine(Utils.TwoDToIso(character.Tile.X-0.5f, character.Tile.Y- 0.5f, character.Tile.Z), Utils.TwoDToIso(character.Tile.X + 0.5f, character.Tile.Y + 0.5f, character.Tile.Z), Color.blue, 1);
             * Debug.DrawLine(Utils.TwoDToIso(character.Tile.X - 0.5f, character.Tile.Y + 0.5f, character.Tile.Z), Utils.TwoDToIso(character.Tile.X + 0.5f, character.Tile.Y - 0.5f, character.Tile.Z), Color.blue, 1);*/
            GameObject tile_go = WorldController.Instance.TileSpriteController.GetGOForTile(character.Tile);

            tile_go.GetComponent <SpriteRenderer>().color = new Color(0.5f, 1f, 0.5f, 0.75f);
        }