Esempio n. 1
0
    public void Run(Transmission transmission)
    {
        if (characters == null)
        {
            characters = new Dictionary <Transmission, Character>();
            foreach (var nearCity in city.transmissions.Keys)
            {
                Transmission instancedTransmission = city.transmissions[nearCity];
                Character    instancedCharacter    = Instantiate(characterPrefab);
                instancedCharacter.gameObject.SetActive(false);
                characters.Add(instancedTransmission, instancedCharacter);
            }
        }

        CityUI target = cityUIs[transmission.dst];

        if (!characters.ContainsKey(transmission))
        {
            Debug.Log("@ " + transmission);
            characters.Keys.ForEach(Debug.Log);
        }

        Character character = characters[transmission];

        character.Transmission(transmission);
    }
Esempio n. 2
0
    public void MoveUnitToOtherArmy(int unitIndex, Army targetArmy, int amount)
    {
        if ((units.Count - 1) < unitIndex)
        {
            UnityEngine.Debug.LogError("Unit which you want to move to other army is null! count: " + (units.Count - 1) + " index: " + unitIndex);
            return;
        }

        if (amount > units[unitIndex].amount)
        {
            UnityEngine.Debug.LogError("There aren't enough units to move!");
            return;
        }

        targetArmy.AddUnit(new UnitInstance(units[unitIndex].GetUnit(), amount));
        RemoveUnitAtIndex(unitIndex, amount);

        if (ArmyUI.GetCurrentWorldAgentArmy() != null)
        {
            UIManager.instance.WorldAgentPanel.GetArmyUI().Refresh(ArmyUI.GetCurrentWorldAgentArmy());
        }

        if (CityUI.GetCurrentBuildingArmy() != null)
        {
            CityUI.instance.GetArmyUI().Refresh(CityUI.GetCurrentBuildingArmy());
        }
        else if (UtilityBuildingUI.GetCurrentBuildingArmy() != null)
        {
            UtilityBuildingUI.instance.GetArmyUI().Refresh(UtilityBuildingUI.GetCurrentBuildingArmy());
        }
    }
Esempio n. 3
0
    public void TryHack()
    {
        if (isTryingHack)
        {
            return;
        }

        AudioManager.PlaySound("Hacking");
        isTryingHack = true;

        Action <bool> resultCallback = (result) =>
        {
            string audioName = result ? "HackSuccess" : "HackFail";
            AudioManager.PlaySound(audioName);
            isTryingHack = false;
            CityZoomer.instance.ZoomOut();
            transmission.TryHack(result);
        };

        CityUI dst = CityUI.cityUIs[transmission.dst];

        CityZoomer.instance.ZoomIn(dst.transform.position);

        NumPad.instance.Float();

        List <Firewall> firewalls = transmission.firewalls;

        if (firewalls.Count == 0)
        {
            return;
        }

        NumPad.instance.Active(firewalls[firewalls.Count - 1].difficulty, resultCallback);
    }
Esempio n. 4
0
    private void DrawRoads()
    {
        // 도로를 그림
        foreach (var road in roads)
        {
            CityUI city1 = cityUIs[road.city1];
            CityUI city2 = cityUIs[road.city2];

            RoadUI roadUI = Instantiate(roadUIPrafab);
            roadUI.name = road.ToString();
            roadUI.transform.SetParent(roadHolder, false);
            roadUI.SetRoad(road);

            // 방향
            Vector2 dir = city2.transform.position - city1.transform.position;

            // 위치
            Vector2 roadCenter = (city1.transform.position + city2.transform.position) / 2;
            roadUI.transform.position = roadCenter;

            // 각도
            float angle    = Mathf.Atan2(dir.y, dir.x) * 180 / 3.14f;
            float distance = dir.magnitude;
            roadUI.transform.rotation = Quaternion.Euler(0, 0, angle);

            // 길이
            RectTransform roadRectTransform = roadUI.GetComponent <RectTransform>();
            Vector2       sizeDelta         = roadRectTransform.sizeDelta;
            sizeDelta.x = distance / canvas.transform.localScale.x;
            roadRectTransform.sizeDelta = sizeDelta;

            // 도로 완료
            roadUI.gameObject.SetActive(true);
        }
    }
    /***************************************************
    ***  METHODS               ************************
    ***************************************************/

    /********  PUBLIC           ************************/

    // Use this for initialization
    public void Start()
    {
        m_camTransitionSc  = GameObject.FindWithTag("CameraTransition").GetComponent <CameraTransition>();
        m_closeViewCamera  = gameObject.transform.parent.gameObject.GetComponent <City>().m_closeViewCamera;
        m_cityCameraCanvas = m_camTransitionSc.m_cityCameraCanvas;
        m_cityCameraCanvas.GetComponent <GraphicRaycaster>().enabled = false;
        m_cityUIScript = GameObject.Find("City Camera Canvas").GetComponent <CityUI>();
    }
Esempio n. 6
0
    public void Transmission(Transmission transmission)
    {
        isDisabled = false;
        gameObject.SetActive(true);
        this.transmission           = transmission;
        transmission.dst.OnDestroy += VictoryAnimation;

        CityUI src = CityUI.cityUIs[transmission.src];

        transform.position = src.transform.position;
    }
Esempio n. 7
0
 void Awake()
 {
     if (I == null)
     {
         I = this;
     }
     else
     {
         Destroy(gameObject);
     }
 }
Esempio n. 8
0
    public CityData(City city, string name)
    {
        this.name  = name;
        sresources = new SStoreableResources(city);

        CityUI cui = CityUI.I;

        purchases = new bool[cui.upgrades.Count];
        for (int i = 0; i < cui.upgrades.Count; i++)
        {
            purchases[i] = cui.upgrades[i].purchased;
        }
    }
Esempio n. 9
0
    private void SelectUnit(Unit unit, City city)
    {
        selectedUnit = unit;
        moveZone.Clear();
        fireZone.Clear();

        fireTargetCoord = Empty;
        moveTargetCoord = Empty;
        turnTargetCoord = Empty;

        moveMarkersView.Hide();
        fireMarkersView.Hide();
        moveZoneMarkersView.Hide();
        selectedMarkersView.Hide();

        moveSelector.Hide();
        fireSelector.Hide();
        if (unit == null)
        {
            gameUI.ShowUnit(null);
            if (city != null && city.Faction == currentFaction)
            {
                CityUI.ShowCityUI(city, game);
            }
            return;
        }
        if (unit.Faction != currentFaction)
        {
            selectedUnit = null;
            gameUI.ShowUnit(null);
            return;
        }
        gameUI.ShowUnit(unit);
        selectedCoord = unit.Coordinate;
        selectedMarkersView.Show(mapView.CellCoordToPosition(selectedCoord));
        if (selectedUnit.ActionPoints > 0)
        {
            moveZone = game.Map.GetMoveZone(unit);
            var moveCoords = moveZone.GetCoordList();
            fireZone = game.Map.GetFireZoneForMoveZone(unit, moveZone);
            var fireCoords = fireZone.GetCoordList();
            moveZoneMarkersView.Show(CoordToPositions(moveCoords));
            fireMarkersView.Show(CoordToPositions(fireCoords));
        }
        if (unitTargetPoints.ContainsKey(selectedUnit))
        {
            ShowCurrentPath(selectedUnit, unitTargetPoints[selectedUnit]);
        }
    }
Esempio n. 10
0
    public void MoveUnitToSecondArmy()
    {
        Army worldAgentArmy   = ArmyUI.GetCurrentWorldAgentArmy();
        Army currBuildingArmy = null;

        if (UIManager.instance.ExchangePanel.IsOpened())
        {
            worldAgentArmy   = UIManager.instance.ExchangePanel.GetEnteredAgent().GetArmy();
            currBuildingArmy = UIManager.instance.ExchangePanel.GetDockAgent().GetArmy();
        }
        else if (CityUI.GetCurrentBuildingArmy() != null)
        {
            if (CityUI.instance.IsSelectedWorldAgentDockedInThisCity())
            {
                currBuildingArmy = CityUI.GetCurrentBuildingArmy();
            }
        }
        else if (UtilityBuildingUI.GetCurrentBuildingArmy() != null)
        {
            if (UtilityBuildingUI.instance.IsSelectedWorldAgentDockedInThisUtilityBuilding())
            {
                currBuildingArmy = UtilityBuildingUI.GetCurrentBuildingArmy();
            }
        }

        if (worldAgentArmy != null && currBuildingArmy != null)
        {
            CloseInfoWindow();

            if (myArmyUI.isItCity)
            {
                currBuildingArmy.MoveUnitToOtherArmy(index, worldAgentArmy);
            }
            else
            {
                worldAgentArmy.MoveUnitToOtherArmy(index, currBuildingArmy);
            }

            if (UIManager.instance.ExchangePanel.IsOpened())
            {
                UIManager.instance.ExchangePanel.Refresh();
            }
        }

        AudioManager.instance.ClickButton();
    }
Esempio n. 11
0
 protected void rptCity_ItemDataBound(object sender, System.Web.UI.WebControls.RepeaterItemEventArgs e)
 {
     if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
     {
         AreaUI areaUI = ((AreaUI)e.Item.DataItem);
         if (areaUI.Cities != null && areaUI.Cities.Count > 0)
         {
             ((CheckBox)e.Item.FindControl("cbArea")).Checked = areaUI.Cities.TrueForAll(r => r.IsSelected == true);
             foreach (ListItem item in ((CheckBoxList)e.Item.FindControl("cblCities")).Items)
             {
                 Int64  CityId = Convert.ToInt64(item.Value);
                 CityUI c      = areaUI.Cities.Find(r => r.CityId == CityId);
                 item.Selected = c.IsSelected;
             }
         }
     }
 }
Esempio n. 12
0
    private void InitializeCitys()
    {
        // 도시들 초기화
        citys          = new Dictionary <string, City>();
        cityUIs        = new Dictionary <City, CityUI>();
        destroyedCitys = new Progress(cityDatas.Count);
        foreach (var cityData in cityDatas)
        {
            string name = cityData.name;
            City   city = new City(cityData);
            city.OnDestroy  += OnDestroyCity;
            city.OnRecovery += OnRecoveryCity;
            citys.Add(name, city);

            CityUI cityUI = cityData.cityUI;
            cityUIs.Add(city, cityUI);
            cityUI.SetCity(city);
        }
    }
Esempio n. 13
0
    public override void load(GameData generic)
    {
        CityData data = generic as CityData;

        resources[LIGHT]         = data.sresources.light;
        resources[UNITY]         = data.sresources.unity;
        resources[STAR_CRYSTALS] = data.sresources.star_crystals;
        resources[MINERALS]      = data.sresources.minerals;
        resources[ARELICS]       = data.sresources.arelics;
        resources[ERELICS]       = data.sresources.erelics;
        resources[MRELICS]       = data.sresources.mrelics;

        CityUI cui = CityUI.I;

        for (int i = 0; i < cui.upgrades.Count; i++)
        {
            cui.selected_upgrade_ID = cui.upgrades[i].ID;
            cui.purchase_upgrade();
        }
    }
Esempio n. 14
0
 private void Awake()
 {
     instance = this;
 }