예제 #1
0
파일: Bypass.cs 프로젝트: novodantis/LD42
    public bool CheckUnique(Starsystem _lastNode)
    {
        // if we join to this, will we be duplicating?
        foreach (Bypass b in localEconomy.allBypasses)
        {
            if (b.nodes[0] == nodes[0])
            {
                // same start
                if (b.GetLastNode() == _lastNode)
                {
                    // its the same path
                    return(false);
                }
            }
            // check inverse
            if (b.nodes[0] == _lastNode)
            {
                // start matches end
                if (b.GetLastNode() == nodes[0])
                {
                    // its the same path in reverse
                    return(false);
                }
            }
        }

        return(true);
    }
예제 #2
0
        public ActionResult StarSystemDetails(int gameID, int hexX, int hexY)
        {
            Debug.WriteLine($"StarSystemDetails HexX:{hexX} HexY:{hexY}");
            Game game = GameState.Game;

            if (hexX < 0 || hexY < 0 ||
                game == null || game.Sector == null)
            {
                return(PartialView("_Starsystem", new ViewStarSystem()));
            }

            SafeUser   user   = Auth.User;
            Starsystem system = game.Sector.StarsystemFromHex(new HexCoordinate(hexX, hexY));

            // Check to determine if the player is within a civilization that has visited the system
            var playerCivilizations = game.Civilizations
                                      .Where(x => x.PlayerOwnsCivilization(user.ID))
                                      .Where(x => x.HasVisitedSystem(system.ID))
                                      .ToList();

            if (!RequireGMAdminAttribute.IsGMOrAdmin() && playerCivilizations.Count == 0)
            {
                return(PartialView("_Starsystem", new ViewStarSystem()));
            }

            return(PartialView("_Starsystem", new ViewStarSystem
            {
                User = game.Players.Where(x => x.User.ID == user.ID).First(),
                System = system,
                HeaderHotLink = true
            }));
        }
예제 #3
0
    public void SelectStarsystem(Starsystem _selected)
    {
        selectedTarget = _selected;
        systemSelected = true;

        if (standardCam.enabled)
        {
            // not in planet view
            ResetCamTarget();
            standardCam.enabled = false;
            Debug.Log("Not yet selected a planet");
        }
        else
        {
            // currently viewing another planet
            Debug.Log("Selecting another planet");
        }
        viewTarget   = selectedTarget.transform.position;
        viewStart    = orbitCam.target.position;
        viewProgress = 0;

        orbitCam.enabled = true;

        userInterface.starsystemPanel.DisplayValuesFor(selectedTarget);
    }
예제 #4
0
    public void Update()
    {
        if (Input.GetMouseButtonDown(0))
        {
            //Debug.Log("Selecting...");

            RaycastHit newHit = new RaycastHit();

            bool hasHit = Physics.Raycast(cameraObject.ScreenPointToRay(Input.mousePosition), out newHit);
            if (hasHit)
            {
                Debug.Log("Hit object: " + newHit.collider.gameObject.name);
                Starsystem _toSelect = newHit.collider.gameObject.GetComponent <Starsystem>();
                if (_toSelect != null)
                {
                    Debug.Log("Object selected has Starsystem component!");
                    SelectStarsystem(_toSelect);
                }
                else
                {
                    Debug.Log("Hit something else");
                }
            }
            else
            {
            }
        }

        if (viewProgress < 1)
        {
            // lerp view
            viewProgress += Time.deltaTime * camLerpSpeed;
            viewLocus.transform.position = Vector3.Lerp(viewStart, viewTarget, tweenCurve.Evaluate(viewProgress));
        }
    }
예제 #5
0
파일: Bypass.cs 프로젝트: novodantis/LD42
 private void Complete(Starsystem _lastNode)
 {
     // finish route
     worth = ProjectProfit(_lastNode);
     AddNode(_lastNode);
     completed = true;
     updateVis = true;
     localEconomy.Process(false);
 }
예제 #6
0
파일: Bypass.cs 프로젝트: novodantis/LD42
 public bool CheckUniqueNode(Starsystem _node)
 {
     foreach (Starsystem n in nodes)
     {
         if (_node == n)
         {
             return(false);
         }
     }
     return(true);
 }
예제 #7
0
파일: Bypass.cs 프로젝트: novodantis/LD42
 public bool Begin(Starsystem _start)
 {
     if (_start.destroyed)
     {
         return(false);
     }
     else
     {
         // Start!
         AddNode(_start);
         return(true);
     }
 }
예제 #8
0
파일: Bypass.cs 프로젝트: novodantis/LD42
    public bool Route(Starsystem _newNode)
    {
        if (_newNode == nodes[nodes.Count - 1])
        {
            Debug.LogWarning("Same Node!");
        }
        else if (CheckUniqueNode(_newNode))
        {
            if (_newNode.destroyed)
            {
                // valid step, check distance
                if (CheckRange(_newNode.transform.position))
                {
                    // close enought to link
                    AddNode(_newNode);
                    return(true);
                }
                else
                {
                    // too far to link
                    Debug.LogWarning("Link too far: " + Vector3.Distance(_newNode.transform.position, nodes[nodes.Count - 1].transform.position));
                }
            }
            else
            {
                if (CheckUnique(_newNode))
                {
                    // finish if you can
                    int _cost = GetCost(true);
                    if (localEconomy.Pay(_cost))
                    {
                        Complete(_newNode);
                        return(true);
                    }
                    else
                    {
                        Debug.LogWarning("Cannot afford bypass, cost: " + _cost);
                    }
                }
            }
        }
        else
        {
            // already have this node in the bypass
        }

        return(false);
    }
예제 #9
0
파일: Bypass.cs 프로젝트: novodantis/LD42
 private void AddNode(Starsystem _node)
 {
     nodes.Add(_node);
     updateVis = true;
 }
예제 #10
0
파일: Bypass.cs 프로젝트: novodantis/LD42
 public float ProjectProfit(Starsystem _lastSystem)
 {
     return(((nodes[0].population * _lastSystem.population) / 2) * (nodes.Count + 1));
 }
예제 #11
0
    public void DisplayValuesFor(Starsystem _thisSystem)
    {
        systemDisplayed        = _thisSystem;
        bypassCostDisplay.text = "";

        if (systemDisplayed.destroyed)
        {
            systemStats.SetActive(false);
            systemButtons.SetActive(false);
            bypassProfitProjection.SetActive(false);
            nameDisplay.text = systemDisplayed.gameObject.name + " (destroyed)";

            if (!routingMode)
            {
                startRouteButton.SetActive(false);
            }
            else
            {
                startRouteButton.SetActive(true);
                if (newBypass.CheckRange(systemDisplayed.transform.position))
                {
                    bypassCostDisplay.text = "CONNECT";
                }
                else
                {
                    bypassCostDisplay.text = "OUT OF RANGE";
                }
            }
        }
        else
        {
            systemStats.SetActive(true);
            systemButtons.SetActive(true);
            startRouteButton.SetActive(true);
            bypassProfitProjection.SetActive(false);
            nameDisplay.text = systemDisplayed.gameObject.name;

            populationCounter.text = (Mathf.Round(systemDisplayed.population * 10f) / 10f) + " billion";
            gdpCounter.text        = (Mathf.Round(systemDisplayed.gdp * 10f) / 10f) + " mtons";
            incomeCounter.text     = (Mathf.Round((systemDisplayed.population * systemDisplayed.gdp) * 100f) / 100f).ToString();

            if (newBypass != null && routingMode)
            {
                if (newBypass.nodes.Count > 0 && newBypass.GetLastNode() != systemDisplayed)
                {
                    if (newBypass.CheckUniqueNode(systemDisplayed))
                    {
                        if (newBypass.CheckUnique(systemDisplayed))
                        {
                            if (newBypass.CheckRange(systemDisplayed.transform.position))
                            {
                                // could complete here
                                bypassCostDisplay.text = "-" + newBypass.GetCost(true);
                                bypassProfitProjection.SetActive(true);
                                bypassProfitDisplay.text = "+" + newBypass.ProjectProfit(systemDisplayed);
                            }
                            else
                            {
                                bypassCostDisplay.text = "OUT OF RANGE";
                            }
                        }
                        else
                        {
                            bypassCostDisplay.text = "ALREADY MADE";
                        }
                    }
                    else
                    {
                        bypassCostDisplay.text = "CANNOT RE-TREAD";
                    }
                }
                else
                {
                    bypassCostDisplay.text = "BUILDING...";
                }
            }
        }



        gameObject.SetActive(true);
    }