예제 #1
0
    public List <List <Node> > nodeMap;  //eg. (3,7) = nodeMap[7][3]

    public void InitNodeMap(SettlementData _settlementData, float _nodeCost)
    {
        height = _settlementData.height;
        width  = _settlementData.width;

        nodeMap = new List <List <Node> > ();

        for (int y = 0; y < height; y++)
        {
            List <Node> tempList = new List <Node> ();

            for (int x = 0; x < width; x++)
            {
                Node tempNode = new Node();
                tempNode.pos = _settlementData.GetDataAt(x, y).pos;

                tempNode.height    = _settlementData.GetDataAt(x, y).height;
                tempNode.steepness = _settlementData.GetDataAt(x, y).steepness;

                tempNode.isRoad     = _settlementData.GetDataAt(x, y).IsRoad();
                tempNode.isBuilding = _settlementData.GetDataAt(x, y).IsBuilding();

                tempNode.SetDefaultCost(_nodeCost);

                tempList.Add(tempNode);
            }

            nodeMap.Add(tempList);
        }


        Debug.Log("DEBUG");
    }
예제 #2
0
    private void PlaceBottomSettlement(Tile tile)
    {
        int tileX  = tile.x;
        int tileY  = tile.y;
        int offset = tileY % 2;
        int x      = (2 * tileX) + 1 + offset;
        int y      = tileY + 1;
        //print("Placing settlement around tile (" + x + "," + y + ")");
        //create game object, place in hierarchy, set name


        GameObject     settlement     = (GameObject)Instantiate(settlementPrefab);
        SettlementData settlementData = settlement.GetComponent <SettlementData>();

        settlementData.setPosition(x, y);

        settlement.transform.parent = settlementSpotsGameObject.transform;
        settlement.transform.name   = "Settlement (" + x + "," + y + ")";

        //set settlement position
        Vector2 gridPos  = new Vector2(tileX, tileY);
        Vector3 worldPos = CalcWorldPosTiles(gridPos);

        worldPos.y = worldPos.y - (hexHeight / 2);
        settlement.transform.position = worldPos;


        settlements[x, y] = new Settlement(settlement, x, y);
    }
예제 #3
0
        //showInfo
        public void SetSettlementInfo(UInt64 objGUID, int headID, string nickName, int kills, int death, int asstimes, int level, int totalcp, int lasthit, EntityCampType camp)
        {
            SettlementData ssd = new SettlementData();

            ssd.Init(objGUID, headID, nickName, level, kills, death, asstimes, totalcp, lasthit, camp);
            mListMentDate.Add(ssd);
        }
예제 #4
0
 public SettlementData(SettlementData oldSettlementData, List <Resource> newResources)
 {
     planet          = oldSettlementData.planet;
     cosmicPortData  = oldSettlementData.cosmicPortData;
     manufactoryData = oldSettlementData.manufactoryData;
     starLabsData    = oldSettlementData.starLabsData;
     resources       = newResources;
 }
예제 #5
0
    public void Setup(Vector2Int _start, Vector2Int _goal, SettlementData _settlementData, float _nodeCost, float _maxRoadSteepness)
    {
        startPos = _start;
        goalPos  = _goal;

        currentNodeManager = new NodeManager();
        currentNodeManager.InitNodeMap(_settlementData, _nodeCost);

        maxSteepness = _maxRoadSteepness;
    }
    /* Stores each value held in settlement inside the gameobject itself
     * /* reads settlement data and uses to determine settlement colour and scale
     */
    private void settlementModifier(GameObject placedSettlement, SettlementData data)
    {
        placedSettlement.name = data.headname;


        GameObject settlementModel = placedSettlement.transform.GetChild(0).gameObject;

        float newScale = settlementModel.transform.localScale.x * checkScale(data.extent);

        settlementModel.transform.localScale += new Vector3(newScale, newScale, newScale);
    }
 void _Packet(ScNpcDatingSettlement msg)
 {
     if (datingSettlement == null)
     {
         datingSettlement = new SettlementData();
     }
     datingSettlement.finishedEventIds = msg.finishedEventIds;
     datingSettlement.moodValue        = msg.moodValue;
     datingSettlement.lvIconName       = msg.lvIconName;
     datingSettlement.addGoodFeelValue = msg.addGoodFeelValue;
     DispatchModuleEvent(EVENT_REFRESH_WINDOW_DATA);
 }
예제 #8
0
    protected override CosmicPortData GetInstitutionSaveData()
    {
        var            playerData     = PlayerDataManager.Instance.PlayerData;
        SettlementData settlementData = null;

        if (playerData != null)
        {
            settlementData = playerData.GetSettlementData(Settlement.Instance.Planet);
        }

        var data = settlementData == null ? null : settlementData.cosmicPortData;

        return(data);
    }
예제 #9
0
    public SettlementData CreateSaveData()
    {
        var cosmicPortData  = CosmicPort.CreateSaveData();
        var manufactoryData = Manufactory.CreateSaveData();
        var starLabsData    = StarLabs.CreateSaveData();
        // FIXME: temporary (will modify since the resources are updated directly from the playerDataManager's settlements data
        var productionData = new ProductionData(0, new List <Resource>());
        var resources      = ResourcesModule.resources;

        var studiesSaveData = StudiesManager.Instance.CreatSaveData();

        var settlementData = new SettlementData(planet, cosmicPortData, manufactoryData, starLabsData, studiesSaveData, productionData, resources);

        return(settlementData);
    }
예제 #10
0
    public void SaveSettlementData(Planet planet, SettlementData settlementData)
    {
        switch (planet)
        {
        case Planet.Earth:
            earthData = settlementData;
            break;

        case Planet.Moon:
            moonData = settlementData;
            break;

        case Planet.Mars:
            marsData = settlementData;
            break;
        }
    }
예제 #11
0
 /// <summary>
 /// 注销
 /// </summary>
 protected virtual void UnRegist()
 {
     MsgHander.UnRegist(0xC111, S2C_GetBattleSettlement);
     MsgHander.UnRegist(0xC109, S2C_UpdateBattleRank);
     MsgHander.UnRegist(0xC110, S2C_UpdateBattleInfo);
     MsgHander.UnRegist(0xC114, S2C_UpdateFightersInfo);
     MsgHander.UnRegist(0xC113, S2C_UpdateGoBackInfo);
     MsgHander.UnRegist(0xC115, S2C_GetBattleChannel);
     MsgHander.UnRegist(0xC149, S2C_GetBattleCountDown);
     settlementData = null;
     failyState     = null;
     demonState     = null;
     goBackCD       = 0;
     channel        = 0;
     CountDown      = 0;
     CampScore.Clear();
     rankListInfo.Clear();
 }
예제 #12
0
    /// <summary>
    /// 获取火焰山战场结算数据
    /// </summary>
    private void S2C_GetBattleSettlement(Pt _pt)
    {
        pt_mountain_flames_win_c111 pt = _pt as pt_mountain_flames_win_c111;

        if (pt != null)
        {
            //Debug.Log("  获取火焰山战场结算数据 ");
            if (settlementData == null)
            {
                settlementData = new SettlementData(pt);
            }
            else
            {
                settlementData.Update(pt);
            }
            GameCenter.uIMng.GenGUI(GUIType.BATTLEFIELDSETTMENT, true);
        }
    }
예제 #13
0
    public void SaveSettlementResources(Planet planet, List <Resource> resources)
    {
        SettlementData oldData = null;

        switch (planet)
        {
        case Planet.Earth:
            oldData = earthData;
            break;

        case Planet.Moon:
            oldData = moonData;
            break;

        case Planet.Mars:
            oldData = marsData;
            break;
        }

        List <Resource> newResources = new List <Resource>(oldData.resources);

        for (int i = 0; i < newResources.Count; i++)
        {
            newResources[i].ChangeAmount(resources[i].Amount);
        }

        var newSettlementData = new SettlementData(oldData, newResources);

        switch (planet)
        {
        case Planet.Earth:
            earthData = newSettlementData;
            break;

        case Planet.Moon:
            moonData = newSettlementData;
            break;

        case Planet.Mars:
            marsData = newSettlementData;
            break;
        }
    }
예제 #14
0
    private void Start()
    {
        ProductionManager.Instance.AddUIManager(this);

        productionData = PlayerDataManager.Instance.PlayerData.GetSettlementData(settlement.Planet);

        for (int i = 0; i < inventoryList.transform.childCount; i++)
        {
            inventoryResources.Add(
                inventoryList.transform.GetChild(i).GetComponent <ResourceEntry>()
                );
        }

        for (int i = 0; i < inventoryUpgradesList.transform.childCount; i++)
        {
            inventoryUpgradesResources.Add(
                inventoryUpgradesList.transform.GetChild(i).GetComponent <ResourceUpgradeEntry>()
                );
        }
    }
예제 #15
0
    void ShowSettlement()
    {
        SettlementData settlementData = GameCenter.battleFightMng.settlementData;

        if (settlementData != null)
        {
            if (win != null)
            {
                win.SetActive(settlementData.fightState == 1);
            }
            if (fail != null)
            {
                fail.SetActive(settlementData.fightState == 0);
            }
            if (draw != null)
            {
                draw.SetActive(settlementData.fightState < 0);
            }
        }

        CancelInvoke("ShowSettleUi");
        Invoke("ShowSettleUi", 2.0f);
    }
    /* Given data on a settlement, places a settlement at its position and
     * Does not place settlement if it's waaaay outside the map's bounds*/
    void placeSettlement(SettlementData settlementData)
    {
        string x = settlementData.eastings;
        string y = settlementData.northings;


        Vector2    gridReference = new Vector2(float.Parse(x), float.Parse(y));
        float      rayHeight     = 1000f;                                                    //height to fire ray from
        RaycastHit settlementPosition;
        Vector2    islandPoint = ConversionHelper.GridReferenceToUnityCoords(gridReference); //converting world point to an island point

        //fire ray directly downwards from above the given point, place settlement where it lands
        Vector3 rayOrigin = new Vector3(islandPoint.x, rayHeight, islandPoint.y);

        if (Physics.Raycast(rayOrigin, Vector3.down, out settlementPosition))
        {
            GameObject placedSettlement = (GameObject)Instantiate(settlementPrefab, settlementPosition.point, Quaternion.identity);

            SettlementInformation settlementInfo = placedSettlement.GetComponent <SettlementInformation> ();
            settlementInfo.setSettlementInfo(settlementData);
            settlementModifier(placedSettlement, settlementData);
        }
    }
예제 #17
0
    private IEnumerator Start()
    {
        yield return(SceneLoader.Instance.WaitForLoading());

        var            playerData     = PlayerDataManager.Instance.PlayerData;
        SettlementData settlementData = null;

        if (playerData != null)
        {
            settlementData = playerData.GetSettlementData(planet);
        }

        if (playerData == null || settlementData == null)
        {
            Debug.LogWarning($"Settlement data is null");
            SaveDataIsNull();
        }
        else
        {
            SetSavableData(settlementData);
        }

        SceneLoader.Instance.RemoveSaveDataWaiter(this);
    }
예제 #18
0
    // Update is called once per frame
    void Update()
    {
        if (Input.GetMouseButtonDown(0))
        {
            //Set up the new Pointer Event
            m_PointerEventData = new PointerEventData(m_EventSystem);
            //Set the Pointer Event Position to that of the mouse position
            m_PointerEventData.position = Input.mousePosition;

            //Create a list of Raycast Results
            List <RaycastResult> results = new List <RaycastResult>();

            //Raycast using the Graphics Raycaster and mouse click position
            m_Raycaster.Raycast(m_PointerEventData, results);

            //For every result returned, output the name of the GameObject on the Canvas hit by the Ray
            foreach (RaycastResult result in results)
            {
                Debug.Log("Hit UI " + result.gameObject.name);
            }


            if (results.Count > 0)
            {
                return;
            }



            Ray          ray = camera.ScreenPointToRay(Input.mousePosition);
            RaycastHit[] hits;
            Vector3      forward = transform.TransformDirection(Vector3.forward) * 100;

            //Ray ray = new Ray(camera.ScreenToWorldPoint(Input.mousePosition), forward);



            //Ray ray = camera.ScreenPointToRay(Input.mousePosition);
            //Debug.DrawRay(camera.ScreenToWorldPoint(Input.mousePosition), forward,Color.red, 1);
            Debug.DrawRay(ray.origin, ray.direction);

            //get all the raycast hits and order them by which was hit first
            hits = Physics.RaycastAll(ray).OrderBy(h => h.distance).ToArray();;

            //print("Length " + hits.Length);
            for (int i = 0; i < hits.Length; i++)
            {
                //print(i);
                RaycastHit hit = hits[i];
                //print("i: " + i + " " + hit.transform.tag);

                if (hit.transform.tag == "Settlement")
                {
                    print("Settlment clicked");
                    Transform      settlementTransform = hit.transform.parent;
                    SettlementData settlementData      = settlementTransform.GetComponent <SettlementData>();
                    int            x = settlementData.getX();
                    int            y = settlementData.getY();

                    gameManager.settlementClicked(x, y);
                    //print("Settlement: (" + x + "," + y + ")");
                    //gridLogic.highlightSurroundingRoads(settlementData.getX(), settlementData.getY());
                    //gridLogic.highlightSurroundingSettlements(settlementData.getX(), settlementData.getY());
                    //gridLogic.highlightSurroundingTiles(settlementData.getX(), settlementData.getY());
                    //break;
                }
                if (hit.transform.tag == "Road")
                {
                    print("Road clicked");
                    Transform roadTransform  = hit.transform.parent;
                    RoadData  settlementData = roadTransform.GetComponent <RoadData>();
                    int       x = settlementData.getX();
                    int       y = settlementData.getY();

                    gameManager.roadClicked(x, y);
                    //break;
                }
                if (hit.transform.tag == "Tile")
                {
                    print("tile clicked");
                    //Transform tileTransform = hit.transform.parent;

                    //TileData tileData = tileTransform.GetComponent<TileData>();
                    //int x = tileData.getX();
                    //int y = tileData.getY();
                    //print(string.Concat("Center Tile: (", x, ",", y, ") ",tileData.getTokenNumber(), " ", tileData.getResourceType()));


                    ////gridLogic.checkIfNextToWater(x, y);
                    ////deletes
                    ////gridLogic.testDelete(x, y);


                    //break;
                }
                if (hit.transform.tag == "Background")
                {
                    print("Background clicked");
                    gameManager.backgroundClicked();
                    break;
                }
            }
        }
    }
예제 #19
0
 public PlayerData(SettlementData earthData, SettlementData moonData, SettlementData marsData)
 {
     this.earthData = earthData;
     this.moonData  = moonData;
     this.marsData  = marsData;
 }
예제 #20
0
 public void SetSavableData(SettlementData data)
 {
     ResourcesModule = new ResourcesModule(data.resources);
 }
예제 #21
0
    void Awake()
    {
        if (closeBtn != null)
        {
            UIEventListener.Get(closeBtn.gameObject).onClick = delegate {
                GameCenter.uIMng.SwitchToUI(GUIType.NONE);
                GameCenter.duplicateMng.C2S_OutCopy();
            }
        }
        ;
        for (int i = 0, max = uiTog.Length; i < max; i++)
        {
            EventDelegate.Remove(uiTog[i].onChange, uiTogOnChange);
            EventDelegate.Add(uiTog[i].onChange, uiTogOnChange);
        }
    }

    void uiTogOnChange()
    {
        for (int i = 0, max = uiTog.Length; i < max; i++)
        {
            if (uiTog[i].value)
            {
                curChack = i;
            }
        }
        ShowRankUI();
    }

    /// <summary>
    /// 结算排行
    /// </summary>
    void ShowRankUI()
    {
        int myCampFaily = 0; //我方 0仙界 1妖界
        int fightState  = 0; //战况 1胜利2失败3平局 根据这个取结算奖励表的数据

        HideAllItems();
        SettlementData settlementData = GameCenter.battleFightMng.settlementData;

        if (settlementData == null)
        {
            return;
        }
        bool haveSelf = false;
        List <mountain_flames_win> battleRankList = new List <mountain_flames_win>();

        if (settlementData.fightState < 0)//平局
        {
            if (noReward != null)
            {
                noReward.SetActive(false);
            }
            fightState = 3;
        }
        else
        {
            if (noReward != null)
            {
                noReward.SetActive(true);
            }
        }

        if (curChack == 0)//查看仙界排行
        {
            battleRankList = settlementData.failyData;
        }
        else//查看妖界排行
        {
            battleRankList = settlementData.demonData;
        }

        bool fairyWin = false;

        if (settlementData.fightState == 0)//我方失败
        {
            fightState = 2;
            if (GameCenter.mainPlayerMng.MainPlayerInfo.Camp == 1)//我方为仙界
            {
                if (rewardUp10 != null)
                {
                    rewardUp10.gameObject.SetActive(curChack == 0);
                }
                if (rewardUp30 != null)
                {
                    rewardUp30.gameObject.SetActive(curChack == 1);
                }
                myCampFaily = 0;
                fairyWin    = false;
            }
            else
            {
                if (rewardUp10 != null)
                {
                    rewardUp10.gameObject.SetActive(curChack == 1);
                }
                if (rewardUp30 != null)
                {
                    rewardUp30.gameObject.SetActive(curChack == 0);
                }
                fairyWin    = true;
                myCampFaily = 1;
            }
        }
        if (settlementData.fightState == 1)//我方胜利
        {
            fightState = 1;
            if (GameCenter.mainPlayerMng.MainPlayerInfo.Camp == 1)//我方为仙界
            {
                if (rewardUp10 != null)
                {
                    rewardUp10.gameObject.SetActive(curChack == 1);
                }
                if (rewardUp30 != null)
                {
                    rewardUp30.gameObject.SetActive(curChack == 0);
                }
                fairyWin    = true;
                myCampFaily = 0;
            }
            else
            {
                if (rewardUp10 != null)
                {
                    rewardUp10.gameObject.SetActive(curChack == 0);
                }
                if (rewardUp30 != null)
                {
                    rewardUp30.gameObject.SetActive(curChack == 1);
                }
                fairyWin    = false;
                myCampFaily = 1;
            }
        }

        if (fairyWinGo != null)
        {
            fairyWinGo.SetActive(fairyWin);                    //仙界胜利
        }
        if (fairyLoseGo != null)
        {
            fairyLoseGo.SetActive(!fairyWin);                     //仙界失败
        }
        for (int i = 0, max = battleRankList.Count; i < max; i++)
        {
            BattleFieldRankUi item;
            if (!allItems.TryGetValue(i, out item))
            {
                if (rankGrid != null)
                {
                    item = battleFieldRankUi.CreateNew(rankGrid.transform);
                }
                allItems[i] = item;
            }
            item = allItems[i];
            if (item != null)
            {
                item.gameObject.SetActive(true);
            }
            if (item != null)
            {
                item.SetSettlementData(battleRankList[i], i + 1, curChack == myCampFaily, fightState);
            }
            if (battleRankList[i].uid == GameCenter.mainPlayerMng.MainPlayerInfo.ServerInstanceID)
            {
                if (battleFieldRankUi != null)
                {
                    if (curChack == 0)
                    {
                        battleFieldRankUi.SetSettlementData(battleRankList[i], i + 1, curChack == myCampFaily, fightState);
                    }
                    battleFieldRankUi.gameObject.SetActive(true);
                }
                haveSelf = true;
            }
            //item.transform.localPosition = new Vector3(0, 43 * i, 0);  排序bug
            //item.gameObject.SetActive(true);
        }
        if (rankGrid != null)
        {
            rankGrid.repositionNow = true;
        }
        if (!haveSelf)
        {
            battleFieldRankUi.gameObject.SetActive(false);
        }
        if (scrollView != null)
        {
            scrollView.SetDragAmount(0, 0, false);
        }
    }

    void HideAllItems()
    {
        foreach (BattleFieldRankUi item in allItems.Values)
        {
            if (item != null)
            {
                item.gameObject.SetActive(false);
            }
        }
    }
}
 public ColoredTextList_Settlement(SettlementData settlement) {
     _list.Add(new ColoredText(settlement.SettlementSize.GetName()));
     _list.Add(new ColoredText(settlement.Population.ToString()));
     _list.Add(new ColoredText(settlement.CapacityUsed.ToString()));
     _list.Add(new ColoredText("TBD"));  // OPE Used need format
     _list.Add(new ColoredText("TBD"));  // X Used need format
 }
 /* Stores each value held in settlement inside the gameobject itself
  * TODO: remove this step?*/
 public void setSettlementInfo(SettlementData settlementData)
 {
     headname = settlementData.headname;
     extent   = settlementData.extent;
     slug     = settlementData.slug;
 }
 protected override void OnGameDataReset()
 {
     base.OnGameDataReset();
     datingSettlement = null;
 }