Esempio n. 1
0
    //public Vector3Int selectPoint;



    private void Start()
    {
        gc                = GameObject.FindWithTag("GlobalController").GetComponent <GlobalController>();
        isBuilding        = false;
        rotateArrows      = false;
        cameraRotating    = false;
        somethingSelected = false;
        Vector3Int size = gc.getSize();

        currentFloor  = 0;
        instanceArray = new List <GameObject>();
        alreadyFilled = new List <Vector3Int>();
        floorParents  = new List <GameObject>();
        InstantiateGridObjects(size);
        buildInt        = gameObject.GetComponent <BuildingInterface>();
        currentInstance = null;
        if (gc.isGameLoaded())
        {
            FillGridWithSave();
        }
        else
        {
            worldGrid = new GameGrid(size);
        }
    }
Esempio n. 2
0
 private void InventoryClick()
 {
     if (PlayerState.GetState() != PlayerState.State.Inventory)
     {
         PlayerState.SetState(PlayerState.State.Inventory);
         BuildingInterface.CloseInterface();
         UI_PlayerInventory2.Open();
     }
     else
     {
         UI_PlayerInventory2.Close();
     }
 }
Esempio n. 3
0
 private void ClickOnBuilding()
 {
     if (PositionInRange(10, Building.BuildingSelected.location))
     {
         if (BuildingInterface.interfaceOpen && BuildingInterface.buildingInterface.building == Building.BuildingSelected)
         {
             BuildingInterface.CloseInterface();
         }
         else
         {
             BuildingInterface.OpenInterface(Building.BuildingSelected);
         }
     }
 }
Esempio n. 4
0
 public static void CloseInterface()
 {
     IsInitBuildingInterfaceTest("CloseInterface");
     if (interfaceOpen)
     {
         buildingInterface.Close();
         buildingInterface = null;
         interfaceOpen     = false;
         PlayerState.SetState(PlayerState.prec_state);
     }
     if (SpaceShip.inventoryOpen)
     {
         SpaceShip.close_interface();
     }
 }
Esempio n. 5
0
    public static void OpenInterface(Building b)
    {
        IsInitBuildingInterfaceTest("OpenInterface");
        if (interfaceOpen)
        {
            CloseInterface();
        }
        BuildingInterface bi = (BuildingInterface)prefads[b.type].Instance();

        bi.building = b;
        bi.Open();
        interfaceOpen     = true;
        buildingInterface = bi;
        PlayerState.SetState(PlayerState.State.BuildingInterface);
    }
Esempio n. 6
0
        public Vector2 PanelPosition(GameObject target, float offset)
        {
            float offsetPosY = target.transform.position.y - offset;

            // Final position of marker above GO in world space
            Vector3 offsetPos = new Vector3(target.transform.position.x, offsetPosY, target.transform.position.z);

            // Calculate *screen* position (note, not a canvas/recttransform position)
            Vector2 canvasPos;
            Vector2 screenPoint = Camera.main.WorldToScreenPoint(offsetPos);

            // Convert screen position to Canvas / RectTransform space <- leave camera null if Screen Space Overlay
            RectTransformUtility.ScreenPointToLocalPointInRectangle(BuildingInterface.GetComponentInParent <Canvas>().gameObject.GetComponent <RectTransform>(), screenPoint, null, out canvasPos);

            // Set
            return(canvasPos);
        }
Esempio n. 7
0
    public override void _EnterTree()
    {
        Camera2D camera = GetNode <Camera2D>("Player/Camera2D");

        CurrentCamera.Init(camera);
        root             = this;
        WorldScreenSizeX = GetViewport().Size.x *CurrentCamera.GetXZoom();
        if (!load)
        {
            TileMap back      = GetNode("Tilemaps").GetNode <TileMap>("0");
            TileMap ground    = GetNode("Tilemaps").GetNode <TileMap>("1");
            TileMap uiground  = GetNode("Tilemaps").GetNode <TileMap>("3");
            TileMap uiground2 = GetNode("Tilemaps").GetNode <TileMap>("2");
            Building.Init(this);
            Loot.Init(this);
            Tree.Init(this);
            BuildingInterface.Init(GetNode("CanvasLayer"));
            Liquid.Init();
            World.Init(ground, uiground, uiground2, back);
            Structure.Init();
            SpaceShip.Init();
            PlayerMouvements.initialPosition = World.spawn;
            InitialiseIverntories();
        }
        else
        {
            TileMap back      = GetNode("Tilemaps").GetNode <TileMap>("0");
            TileMap ground    = GetNode("Tilemaps").GetNode <TileMap>("1");
            TileMap uiground  = GetNode("Tilemaps").GetNode <TileMap>("3");
            TileMap uiground2 = GetNode("Tilemaps").GetNode <TileMap>("2");
            Loot.Init(this);
            Tree.Init(this);
            Building.Init(this);
            BuildingInterface.Init(GetNode("CanvasLayer"));
            World.Init(ground, uiground, uiground2, back, false);
            Save._Load(saveName);
            SpaceShip.Init();
        }
    }
Esempio n. 8
0
 public void _on_LinkBtn_button_down()
 {
     PlayerState.SetState(PlayerState.State.Link);
     Link.Init(sp);
     BuildingInterface.CloseInterface();
 }
Esempio n. 9
0
 public static void Die()
 {
     BuildingInterface.CloseInterface();
     UI_PlayerInventory2.Close();
     PlayerState.SetState(PlayerState.State.Dead);
 }
 void Start()
 {
     buildingInterfaceObject = GameObject.Find("BuildingInterface");
     buildingInterface       = buildingInterfaceObject.GetComponent <BuildingInterface>();
     storageWindow           = buildingInterface.storageWindow;
 }
 void Start()
 {
     buildingInterfaceObject = GameObject.Find("BuildingInterface");
     buildingInterface = buildingInterfaceObject.GetComponent<BuildingInterface>();
     storageWindow = buildingInterface.storageWindow;
 }
Esempio n. 12
0
    public override void _Process(float delta)
    {
        if (!playerInputActive)
        {
            return;
        }

        if (lastState != PlayerState.GetState() || lastSelectedUsable != Player.UsableSelected)
        {
            World.UIBlockTilemap.Clear();
            lastSelectedUsable = Player.UsableSelected;
            lastState          = PlayerState.GetState();
        }

        mousePos = Convertion.Location2WorldFloor(GetGlobalMousePosition());

        //Affichage
        if (PlayerState.GetState() == PlayerState.State.Normal)
        {
            NormalState();
        }
        else if (PlayerState.GetState() == PlayerState.State.Build)
        {
            BuildState();
        }


        /* Inventory Click */
        if (Input.IsActionJustPressed("inventory"))
        {
            InventoryClick();
        }

        /*Escape*/
        if (Input.IsActionJustPressed("escape"))
        {
            if (PlayerState.GetState() == PlayerState.State.Pause)
            {
                PlayerState.SetState(PlayerState.prec_state);
                PauseMenu.Close();
            }
            else if (PlayerState.GetState() == PlayerState.State.Normal)
            {
                PlayerState.SetState(PlayerState.State.Pause);
                PauseMenu.Open();
            }
            else if (PlayerState.GetState() == PlayerState.State.Inventory)
            {
                UI_PlayerInventory2.Close();
            }
            else if (PlayerState.GetState() == PlayerState.State.Build)
            {
                PlayerState.SetState(PlayerState.State.Normal);
            }
            else if (PlayerState.GetState() == PlayerState.State.BuildingInterface)
            {
                BuildingInterface.CloseInterface();
            }
            else if (PlayerState.GetState() == PlayerState.State.Link)
            {
                Link._Link();
                Link.Reset();
                PlayerState.SetState(PlayerState.State.Normal);
            }
        }

        //Inputs
        if (Input.IsActionJustPressed("mouse1"))
        {
            if (PlayerState.GetState() == PlayerState.State.Normal)
            {
                ClickNormalState();
            }
            else if (PlayerState.GetState() == PlayerState.State.Build)
            {
                ClickBuildState();
            }
            if (PlayerState.GetState() == PlayerState.State.Normal || PlayerState.GetState() == PlayerState.State.Build || PlayerState.GetState() == PlayerState.State.BuildingInterface)
            {
                if (Building.HasBuildingSelected)
                {
                    ClickOnBuilding();
                }

                if (SpaceShip.ShipSelected)
                {
                    SpaceShipClick();
                }
            }
            if (PlayerState.GetState() == PlayerState.State.Link)
            {
                if (Building.HasBuildingSelected)
                {
                    ClickOnBuilding2Link();
                }
            }
        }
    }