Пример #1
0
        public void AddMarker(TitanView titan, PlanetView planet)
        {
            var marker = Instantiate(markerControllerPrefab, transform);

            marker.Init(titan, planet);
            markers.Add(marker);
        }
Пример #2
0
        private void Update()
        {
            var        ray        = _camera.ScreenPointToRay(Input.mousePosition);
            PlanetView planetView = null;
            var        hits       = Physics.RaycastAll(ray);
            var        closest    = hits.OrderBy(hit =>
            {
                var mousePoint = hit.point;
                mousePoint.y   = 0f;
                return(Vector3.Distance(hit.transform.position, mousePoint));
            }).FirstOrDefault();

            if (closest.transform)
            {
                planetView = closest.transform.GetComponent <PlanetView>();
            }
            if (planetView != null)
            {
                planetView.IsUnderCursor = true;
                if (Input.GetMouseButtonDown(0))
                {
                    _shipBehaviour.SetTarget(planetView.PlanetBehaviour);
                }
            }

            _interactionData.CurrentlySelectedPlanet.Value = planetView;
        }
Пример #3
0
    public PlanetView GetPlanetView(ushort thingIndex)
    {
        if (planetViews[thingIndex] != null)
        {
            return(planetViews[thingIndex]);
        }

        if (activePlanetViews.Count >= MaxActivePlanetViews)
        {
            universe.ReturnPlanet(activePlanetViews[0].Planet);
        }

        Planet planet = universe.GetPlanet(thingIndex);

        if (planet == null)
        {
            return(null);
        }

        PlanetView planetView = universeFactory.GetPlanet(planet.Height);

        planetView.InitPlanet(planet, this);

        activePlanetViews.Add(planetView);

        planetViews[thingIndex] = planetView;

        //Debug.Log(planetViews.Count);

        return(planetView);
    }
Пример #4
0
        protected override void OnPrepare(GameState prev, object[] stateParams)
        {
            if (this.App.GameDatabase == null)
            {
                this.App.NewGame(new Random(12345));
                if (stateParams == null || stateParams.Length == 0)
                {
                    int orbitalObjectID = this.App.GameDatabase.GetPlayerInfo(this.App.LocalPlayer.ID).Homeworld.Value;
                    stateParams = new object[2]
                    {
                        (object)this.App.GameDatabase.GetOrbitalObjectInfo(orbitalObjectID).StarSystemID,
                        (object)orbitalObjectID
                    };
                }
            }
            int stateParam1 = (int)stateParams[0];
            int stateParam2 = (int)stateParams[1];

            this._crits = new GameObjectSet(this.App);
            this._sky   = new Sky(this.App, SkyUsage.InSystem, stateParam1);
            this._crits.Add((IGameObject)this._sky);
            this._camera     = this._crits.Add <OrbitCameraController>();
            this._planetView = this._crits.Add <PlanetView>();
            this._starsystem = new StarSystem(this.App, 1f, stateParam1, Vector3.Zero, true, (CombatSensor)null, false, 0, this is DefenseManagerState, true);
            this._crits.Add((IGameObject)this._starsystem);
            this._starsystem.PostSetProp("CameraController", (IGameObject)this._camera);
            this._starsystem.PostSetProp("InputEnabled", true);
            this.CurrentSystem  = stateParam1;
            this.SelectedObject = stateParam2;
        }
Пример #5
0
    void OnCollisionEnter2D(Collision2D collision)
    {
        if (collision.collider.CompareTag("Planet"))
        {
            if (hasJumped)
            {
                hasJumped = false;
                jumpLevel = 0;
                AudioSource source = GetComponent <AudioSource> ();
                source.clip  = landSounds [Rnd.Int(0, landSounds.Length)];
                source.pitch = Rnd.Float(0.95f, 1.05f);
                source.Play();
            }

            PlanetView    planet = collision.collider.gameObject.GetComponent <PlanetView> ();
            HaloBehaviour halo   = planet.gravityField.GetComponent <HaloBehaviour>();
            Dbg.Log(this, "halo", halo);
            halo.Highlight();
            planet.hasBeenVisited = true;

////			Dbg.Log (this, "collide", collision, collision.collider.tag);
//			//hasLanded = true;
////			boost = 0;
//			currentNoJump = 0;
        }
    }
    public void ReplacePlanetView(PlanetView newValue)
    {
        var index     = GameComponentsLookup.PlanetView;
        var component = (PlanetViewComponent)CreateComponent(index, typeof(PlanetViewComponent));

        component.Value = newValue;
        ReplaceComponent(index, component);
    }
Пример #7
0
 public bool IsConnectedTo(PlanetView other)
 {
     if (ConnectedPlanets == null || ConnectedPlanets.Count == 0)
     {
         return(false);
     }
     return(ConnectedPlanets.Contains(other));
 }
Пример #8
0
    void AdvanceAction(PlanetState previousState, PlanetState currentState)
    {
        // Get planet objects
        previousPlanet = planetMap[previousState];
        curentPlanet   = planetMap[currentState];

        switchTween.Execute(previousPlanet, curentPlanet);
    }
Пример #9
0
    public void TravelToPlanet(PlanetView targetPlanetView)
    {
        ((UniverseEngine.Avatar)universeView.avatarView.UniverseObject).TravelToPlanet((Planet)targetPlanetView.TilemapCircle);
        //Force update to update AvatarView position
        universeView.UpdateUniverse(Time.deltaTime);

        SwitchState(GameLogicState.Travelling);
    }
Пример #10
0
 private void SendToPlanet(EntityView entity, PlanetView planet)
 {
     if (entity != this)
     {
         return;
     }
     SetPlanet(planet);
     SetState(EntityStates.MOVE_TO_PLANET);
 }
Пример #11
0
 private void OnMoveEntities(MoveEntitiesArgs args)
 {
     if (args.From == ConnectedPlanet)
     {
         ConnectedPlanet.RemoveEntity(this);
         ConnectedPlanet = args.To;
         SetState(EntityStates.MOVE_TO_PLANET);
     }
 }
    void Start()
    {
        // get the Planet View component
        planetView = GetComponent <PlanetView>();

        // register callbacks to VuMark Manager
        mVuMarkManager = TrackerManager.Instance.GetStateManager().GetVuMarkManager();
        mVuMarkManager.RegisterVuMarkDetectedCallback(OnVuMarkDetected);
    }
Пример #13
0
 public SystemWidget(App app, string rootPanel)
 {
     this._rootPanel           = rootPanel;
     this.App                  = app;
     this._crits               = new GameObjectSet(this.App);
     this._planetView          = this._crits.Add <PlanetView>();
     this.App.UI.PanelMessage += new UIEventPanelMessage(this.UICommChannel_OnPanelMessage);
     ++SystemWidget.kWidgetID;
     this._widgetID = SystemWidget.kWidgetID;
 }
Пример #14
0
 private void LoadPlanets()
 {
     for (int i = 0; i < 3; i++)
     {
         PlanetView planetView = new PlanetView("Planet" + i, space.Planets[i]);
         planetView.PlanetFree.Click += PlanetButton_Click;
         planetView.PlanetFree.Tag    = i;
         planetLayoutPanel.Controls.Add(planetView);
     }
 }
Пример #15
0
        public void Init(TitanView titan, PlanetView planet)
        {
            Titan            = titan;
            controlledPlanet = planet;
            var image = GetComponentInChildren <Image>();

            if (image != null)
            {
                image.color = titan.Titan.Faction.ID == 0 ? Color.blue : Color.red;
            }
        }
Пример #16
0
    public void Execute(PlanetView oldPlanet, PlanetView newPlanet)
    {
        previousPlanet = oldPlanet;
        currentPlanet  = newPlanet;

        Invoke("GrowPlanet", delayBeforeTween);

        if (currentPlanet.IsFinalState())
        {
            HandleFinalTransition();
        }
        else
        {
            HandleTransition();
        }
    }
Пример #17
0
        public static bool GoToHomeState(TransitionCompleteDelegate onComplete, bool zoom)
        {
            Service.DeployerController.ExitAllDeployModes();
            Service.PvpManager.KillTimer();
            if (zoom)
            {
                PlanetView view = Service.WorldInitializer.View;
                view.ZoomOutImmediate();
                view.ZoomIn();
            }
            HomeState homeState = new HomeState();
            bool      result    = homeState.Setup(onComplete);

            Service.AssetManager.UnloadPreloadables();
            return(result);
        }
Пример #18
0
 public void AddConnectedPlanet(PlanetView other)
 {
     if (IsConnectedTo(other))
     {
         return;
     }
     if (ConnectedPlanets == null)
     {
         ConnectedPlanets = new List <PlanetView>();
     }
     ConnectedPlanets.Add(other);
     if (PlanetAdded != null)
     {
         PlanetAdded.Invoke(other);
     }
 }
Пример #19
0
        public override void Initialize()
        {
            this._sky        = new Sky(this._app, SkyUsage.StarMap, 0);
            this._crits      = new GameObjectSet(this._app);
            this._planetView = this._crits.Add <PlanetView>();
            this._crits.Add((IGameObject)this._sky);
            StationInfo       stationInfo        = this._app.GameDatabase.GetStationInfo(this._stationID);
            OrbitalObjectInfo orbitalObjectInfo1 = this._app.GameDatabase.GetOrbitalObjectInfo(this._stationID);
            OrbitalObjectInfo orbitalObjectInfo2 = this._app.GameDatabase.GetOrbitalObjectInfo(orbitalObjectInfo1.ParentID.Value);

            this._app.UI.SetText(this._app.UI.Path(this.ID, "station_class"), string.Format(App.Localize("@STATION_LEVEL"), (object)stationInfo.DesignInfo.StationLevel.ToString(), (object)stationInfo.DesignInfo.StationType.ToString()));
            this._app.UI.SetText(this._app.UI.Path(this.ID, "upkeep_cost"), string.Format(App.Localize("@STATION_UPKEEP_COST"), (object)GameSession.CalculateStationUpkeepCost(this._app.GameDatabase, this._app.AssetDatabase, stationInfo).ToString()));
            if (stationInfo.DesignInfo.StationType == StationType.NAVAL)
            {
                this._app.UI.SetText(this._app.UI.Path(this.ID, "naval_capacity"), string.Format(App.Localize("@STATION_FLEET_CAPACITY"), (object)this._app.GameDatabase.GetSystemSupportedCruiserEquivalent(this._app.Game, orbitalObjectInfo2.StarSystemID, this._app.LocalPlayer.ID).ToString()));
            }
            else
            {
                this._app.UI.SetVisible(this._app.UI.Path(this.ID, "naval_capacity"), false);
            }
            StarSystemInfo starSystemInfo = this._app.GameDatabase.GetStarSystemInfo(orbitalObjectInfo2.StarSystemID);

            this._app.UI.SetText("gameStationName", orbitalObjectInfo1.Name);
            this._enteredStationName = orbitalObjectInfo2.Name;
            this._app.UI.SetText(this._app.UI.Path(this.ID, "system_name"), string.Format(App.Localize("@STATION_BUILT"), (object)starSystemInfo.Name).ToUpperInvariant());
            this._cameraReduced                 = new OrbitCameraController(this._app);
            this._cameraReduced.MinDistance     = 1002.5f;
            this._cameraReduced.MaxDistance     = 10000f;
            this._cameraReduced.DesiredDistance = 2000f;
            this._cameraReduced.DesiredYaw      = MathHelper.DegreesToRadians(45f);
            this._cameraReduced.DesiredPitch    = -MathHelper.DegreesToRadians(25f);
            this._cameraReduced.SnapToDesiredPosition();
            this._starmapReduced = new StarMap(this._app, this._app.Game, this._sky);
            this._starmapReduced.Initialize(this._crits);
            this._starmapReduced.SetCamera(this._cameraReduced);
            this._starmapReduced.FocusEnabled = false;
            this._starmapReduced.PostSetProp("Selected", this._starmapReduced.Systems.Reverse[starSystemInfo.ID].ObjectID);
            this._starmapReduced.PostSetProp("CullCenter", this._app.GameDatabase.GetStarSystemInfo(starSystemInfo.ID).Origin);
            this._starmapReduced.PostSetProp("CullRadius", 15f);
            DesignInfo di = DesignLab.CreateStationDesignInfo(this._app.AssetDatabase, this._app.GameDatabase, this._app.LocalPlayer.ID, stationInfo.DesignInfo.StationType, stationInfo.DesignInfo.StationLevel, false);

            this._stationModel = new StarSystemDummyOccupant(this._app, this._app.AssetDatabase.ShipSections.First <ShipSectionAsset>((Func <ShipSectionAsset, bool>)(x => x.FileName == di.DesignSections[0].FilePath)).ModelName, stationInfo.DesignInfo.StationType);
            this._stationModel.PostSetScale(1f / 500f);
            this._stationModel.PostSetPosition(this._trans);
        }
Пример #20
0
        public override void Initialize()
        {
            this._sky        = new Sky(this._app, SkyUsage.StarMap, 0);
            this._crits      = new GameObjectSet(this._app);
            this._planetView = this._crits.Add <PlanetView>();
            this._crits.Add((IGameObject)this._sky);
            OrbitalObjectInfo orbitalObjectInfo = this._app.GameDatabase.GetOrbitalObjectInfo(this._planetID);
            StarSystemInfo    starSystemInfo    = this._app.GameDatabase.GetStarSystemInfo(orbitalObjectInfo.StarSystemID);

            this._app.UI.SetText("gameColonyName", orbitalObjectInfo.Name);
            this._enteredColonyName = orbitalObjectInfo.Name;
            this._app.UI.SetVisible(this._app.UI.Path(this.ID, "btnAbandon"), false);
            this._app.UI.SetText(this._app.UI.Path("colonyCreateTitle"), (this._homeworld ? App.Localize("@UI_STARMAP_HOMEWORLD_ESTABLISHED") : App.Localize("@UI_STARMAP_COLONY_ESTABLISHED")) + " - " + starSystemInfo.Name);
            this._cameraReduced                 = new OrbitCameraController(this._app);
            this._cameraReduced.MinDistance     = 2.5f;
            this._cameraReduced.MaxDistance     = 100f;
            this._cameraReduced.DesiredDistance = 50f;
            this._cameraReduced.DesiredYaw      = MathHelper.DegreesToRadians(45f);
            this._cameraReduced.DesiredPitch    = -MathHelper.DegreesToRadians(25f);
            this._cameraReduced.SnapToDesiredPosition();
            this._starmapReduced = new StarMap(this._app, this._app.Game, this._sky);
            this._starmapReduced.Initialize(this._crits);
            this._starmapReduced.SetCamera(this._cameraReduced);
            this._starmapReduced.FocusEnabled = false;
            this._starmapReduced.SetFocus((IGameObject)this._starmapReduced.Systems.Reverse[starSystemInfo.ID]);
            this._starmapReduced.Select((IGameObject)this._starmapReduced.Systems.Reverse[starSystemInfo.ID]);
            this._starmapReduced.SelectEnabled = false;
            this._starmapReduced.PostSetProp("MissionTarget", (object)this._starmapReduced.Systems.Reverse[starSystemInfo.ID].ObjectID, (object)true);
            this._starmapReduced.PostSetProp("CullCenter", this._app.GameDatabase.GetStarSystemInfo(starSystemInfo.ID).Origin);
            this._starmapReduced.PostSetProp("CullRadius", 15f);
            this._app.UI.Send((object)"SetGameObject", (object)this._app.UI.Path(this.ID, "gameStarMapViewport"), (object)this._starmapReduced.ObjectID);
            this.CachePlanet(this._app.GameDatabase.GetPlanetInfo(this._planetID));
            this._planetView.PostSetProp("Planet", this._cachedPlanet != null ? this._cachedPlanet.ObjectID : 0);
            this._app.UI.Send((object)"SetGameObject", (object)this._app.UI.Path(this.ID, "system_details.Planet_panel"), (object)this._planetView.ObjectID);
            StarSystemMapUI.Sync(this._app, orbitalObjectInfo.StarSystemID, this._app.UI.Path(this.ID, "system_map"), true);
            StarSystemUI.SyncSystemDetailsWidget(this._app, "colony_event_dialog.system_details", orbitalObjectInfo.StarSystemID, true, true);
            StarSystemUI.SyncPlanetDetailsControl(this._app.Game, this._app.UI.Path(this.ID, "system_details"), this._planetID);
            StarSystemUI.SyncColonyDetailsWidget(this._app.Game, this._app.UI.Path(this.ID, "colony_details"), orbitalObjectInfo.ID, "");
            this._app.UI.SetVisible(this._app.UI.Path(this.ID, "system_map"), true);
            this._app.UI.SetVisible(this._app.UI.Path(this.ID, "gameStarMapViewport"), false);
            this._app.UI.AddItem(this._app.UI.Path(this.ID, "gameViewportList"), "", 0, App.Localize("@SYSTEMDETAILS_SYS_MAP"));
            this._app.UI.AddItem(this._app.UI.Path(this.ID, "gameViewportList"), "", 1, App.Localize("@SYSTEMDETAILS_STAR_MAP"));
            this._app.UI.SetSelection(this._app.UI.Path(this.ID, "gameViewportList"), 0);
            this._crits.Activate();
        }
Пример #21
0
    public void OnPlanetReturned(Planet planet)
    {
        planetViews[planet.ThingIndex] = null;

        for (int i = 0; i < activePlanetViews.Count; i++)
        {
            if (activePlanetViews[i].Planet == planet)
            {
                PlanetView planetView = activePlanetViews[i];

                universeFactory.ReturnPlanet(planetView);

                activePlanetViews.RemoveAt(i);

                break;
            }
        }
    }
Пример #22
0
 private void InstantiateHexOccupants(HexPos pos, List <HexOccupier> occupants)
 {
     foreach (HexOccupier occupant in occupants)
     {
         if (occupant is UnitModel)
         {
             UnitView newUnit = GameObject.Instantiate(UnitPrefab);
             occupant.CurrentPos = pos;
             newUnit.Model       = (UnitModel)occupant;
         }
         if (occupant is PlanetModel)
         {
             PlanetView newPlanet = GameObject.Instantiate(PlanetPrefab);
             occupant.CurrentPos = pos;
             newPlanet.Model     = (PlanetModel)occupant;
         }
     }
 }
Пример #23
0
 protected override void OnExit()
 {
     this._planetView = (PlanetView)null;
     this._planetWidget.Terminate();
     if (this._cachedPlanet != null)
     {
         this.App.ReleaseObject((IGameObject)this._cachedPlanet);
     }
     this._cachedPlanet      = (StellarBody)null;
     this._cachedPlanetReady = false;
     if (this._cachedStar != null)
     {
         this.App.ReleaseObject((IGameObject)this._cachedStar);
     }
     this._cachedStar               = (StarModel)null;
     this._cachedStarReady          = false;
     this._selectedPlanetToEvacuate = 0;
     base.OnExit();
 }
Пример #24
0
    private IEnumerator LoadPlanets()
    {
        Debug.Log("Load Planets");

        yield return(APIController.GetPlanetsInRange(-1, 10, (List <Planet> planets) =>
        {
            int planetIndex = 0;
            foreach (Planet planet in planets)
            {
                Vector3 planetLocation = planetSelectionPanel.transform.position;
                planetLocation.x = planetSideOffset * (planetIndex + 1);

                StartCoroutine(imageController.GetSprite(planet.image_filename, (Sprite sprite) =>
                {
                    PlanetView planetView = Instantiate(planetViewPrefab, planetSelectionPanel);
                    planetView.InitializePlanet(sprite, planet.name, planet.id);
                    planetView.transform.position = planetLocation;
                }));
                planetIndex++;
            }
        }));
    }
Пример #25
0
    // Use this for initialization
    void Start()
    {
        // Get the Planet View component
        planetView = GetComponent <PlanetView>();



        // Register callbacks to VuMark Manager
        mVuMarkManager = TrackerManager.Instance.GetStateManager().GetVuMarkManager();
        mVuMarkManager.RegisterVuMarkDetectedCallback(OnVuMarkDetected);


        mVuMarkManager.RegisterVuMarkLostCallback(OnVuMarkLost);

        // Deactivate all Planet views
        //solarSystem.SetActive(false);
        foreach (GameObject item in bodiesObj)
        {
            Debug.Log("item : " + item);
            //Debug.Log(item);
            //item.SetActive(false);
        }
    }
Пример #26
0
 private void Awake()
 {
     instance = this;
 }
Пример #27
0
    public void UpdateClickOnPlanetToTravel(UniverseView universeView)
    {
        bool    clickTravel   = false;
        Vector2 clickPosition = Vector2.zero;

        if (Application.platform == RuntimePlatform.Android || Application.platform == RuntimePlatform.IPhonePlayer)
        {
            if (!travelInput)
            {
                if (Input.touchCount == 1 && Input.GetTouch(0).phase == TouchPhase.Began && !InputAreas.IsInputArea(Input.GetTouch(0).position))
                {
                    travelInput = true;
                    travelInputStartPosition = Input.GetTouch(0).position;
                }
                else
                {
                    travelInput = false;
                }
            }
            else
            {
                if (Input.touchCount == 1)
                {
                    if (Input.GetTouch(0).phase == TouchPhase.Ended)
                    {
                        if ((travelInputStartPosition - Input.GetTouch(0).position).magnitude < 10)
                        {
                            clickTravel   = true;
                            clickPosition = Input.GetTouch(0).position;
                        }

                        travelInput = false;
                    }
                }
                else
                {
                    travelInput = false;
                }
            }
        }
        else
        {
            if (!travelInput)
            {
                if (Input.GetMouseButtonDown(0) && !InputAreas.IsInputArea(Input.mousePosition))
                {
                    travelInput = true;
                    travelInputStartPosition = Input.mousePosition;
                }
                else
                {
                    travelInput = false;
                }
            }
            else
            {
                if (Input.GetMouseButtonUp(0))
                {
                    if ((travelInputStartPosition - (Vector2)Input.mousePosition).magnitude < 10)
                    {
                        clickTravel   = true;
                        clickPosition = Input.mousePosition;
                    }

                    travelInput = false;
                }
                else if (!Input.GetMouseButton(0))
                {
                    travelInput = false;
                }
            }
        }

        if (clickTravel)
        {
            Vector2 worldPos          = Camera.main.ScreenToWorldPoint(clickPosition);
            Vector2 worldPosTolerance = Camera.main.ScreenToWorldPoint(clickPosition + Vector2.right * (Screen.dpi > 0 ? Screen.dpi : 72) / 2.54f); //1 cm tolerance

            int clickedThingIndex = universeView.Universe.FindClosestRenderedThing(worldPos, (worldPos - worldPosTolerance).magnitude);

            if (clickedThingIndex >= 0)
            {
                PlanetView targetPlanetView = universeView.GetPlanetView((ushort)clickedThingIndex);
                if (universeView.avatarView.UniverseObject.parent != targetPlanetView.TilemapCircle)
                {
                    GameLogic.Instace.TravelToPlanet(targetPlanetView);
                }
            }
        }
    }
Пример #28
0
 private void PlanetConnectionAdded(PlanetView other)
 {
     PlanetConnectionAddedSignal.Dispatch(new PlanetConnectionArgs(this, other));
 }
Пример #29
0
 public AbstractDeployer()
 {
     this.Reset();
     this.worldView = Service.WorldInitializer.View;
 }
Пример #30
0
 public void SetPlanet(PlanetView planet)
 {
     ConnectedPlanet = planet;
 }