예제 #1
0
        public void CreateUnit(UnitType unit, ProvinceIdentifier province)
        {
            Province mapProvince = _map.GetProvince(province.Province, province.Nation);

            // Get city location
            Vector2 cityPosition = mapProvince.center;

            GameObject soldierGO = Instantiate(_prefabProvider.GetUnitTransform(UnitPrefabType.BASIC_SOLDIER)).gameObject;

            soldierGO.transform.Rotate(Vector3.up, 180);
            GameObjectAnimator soldier = soldierGO.WMSK_MoveTo(cityPosition);

            soldier.autoRotation      = false;
            soldier.terrainCapability = TERRAIN_CAPABILITY.OnlyGround;

            var guid = Guid.NewGuid();

            // Set tank ownership
            soldier.attrib["player"] = 1;
            soldier.attrib["uuid"]   = guid.ToString();
            var createdUnit = _gameState.CreateUnit(new WorldMapGameUnit()
            {
                UnitType = unit,
                Guid     = guid,
                Name     = "SuccessfullyCreated!"
            });

            soldierGO.GetComponent <GameUnitBehavior>().UnitAttributes = createdUnit;
        }
예제 #2
0
 void ShowProvinceResources()
 {
     for (int k = 0; k < map.provinces.Length; k++)
     {
         GameObject resourceIcon = Instantiate
                                       (Resources.Load <GameObject>("Resource/" + provinces[k].getResource()));
         Vector2 position = map.GetProvince(k).center;
         resourceIcon.WMSK_MoveTo(position, true, 1.6f);
     }
 }
예제 #3
0
    public void placeArmyOnMap(int provIndex, Nation nation, int id)
    {
        map = WMSK.instance;
        GameObject armyPrefabInstance = Instantiate(Resources.Load <GameObject>
                                                        ("ToonyTinyPeople/TT_ww1/EarlyEraArmy"));

        WorldMapStrategyKit.Province prov = map.GetProvince(provIndex);
        if (nation.getType() == MyEnum.NationType.major || nation.getType() == MyEnum.NationType.minor)
        {
            if (State.GerEra() == MyEnum.Era.Early)
            {
                armyPrefabInstance = Instantiate(Resources.Load <GameObject>
                                                 // ("ToonyTinyPeople/TT_ww1/EarlyEraArmy"));
                                                     ("ToonyTinyPeople/TT_ww1/EarlyEraArmy"));
            }
        }
        else
        {
            {
                armyPrefabInstance = Instantiate(Resources.Load <GameObject>
                                                     ("Model_Warrior/barbOne"));
            }
        }

        Vector2            position = prov.center;
        GameObjectAnimator army     = armyPrefabInstance.WMSK_MoveTo(position);

        army.gameObject.AddComponent <GenericSoldierController>();
        army.name = id.ToString();



        SkinnedMeshRenderer[] smrs = armyPrefabInstance.GetComponentsInChildren <SkinnedMeshRenderer>();
        foreach (SkinnedMeshRenderer smr in smrs)
        {
            if (smr.name.StartsWith("flagcl"))
            {
                Debug.Log("Army of " + nation.getNationName());
                smr.material = Resources.Load("Flags/Materials/" + nation.getNationName(), typeof(Material)) as Material;
            }
        }
        if (nation.getType() == MyEnum.NationType.major || nation.getType() == MyEnum.NationType.minor)
        {
            army.transform.localScale = new Vector3(0.5f, 0.5f, 0.5f);
        }
        else
        {
            army.transform.localScale = new Vector3(0.2f, 0.2f, 0.2f);
        }
        army.preserveOriginalRotation = true;
        army.terrainCapability        = TERRAIN_CAPABILITY.OnlyGround;
        army.autoScale = true;
        army.group     = 1;
        army.transform.localRotation = Quaternion.Euler(-30f, 180f, 0f);
        army.BlocksRayCast           = true;

        army.attrib["owner"] = nation.getIndex();
        army.attrib["id"]    = id;
    }
예제 #4
0
    public void ToggleProvinceResources()
    {
        map = WMSK.instance;

        App app = UnityEngine.Object.FindObjectOfType <App>();
        Dictionary <int, assemblyCsharp.Province> provinces = State.getProvinces();

        if (State.GetResourceIcons().Count == 0)
        {
            for (int k = 0; k < map.provinces.Length; k++)
            {
                GameObject resourceIcon = Instantiate
                                              (Resources.Load <GameObject>("ResourceMap/" + provinces[k].getResource()));
                Vector2            position = map.GetProvince(k).center;
                GameObjectAnimator icon     = resourceIcon.WMSK_MoveTo(position, true, 1f);

                //  icon.WMSK_MoveTo(position, true, 1.6f);
                icon.transform.localScale = new Vector3(0.5f, 0.5f, 1.0f);
                // resourceIcon.SetActive(false);
                icon.autoScale = true;
                icon.group     = 0;
                //   icon.GetComponent<SpriteRenderer>().enabled = false;
                icon.visible = false;
                State.addResourceIcon(icon);
            }
            map.VGOToggleGroupVisibility(0, false);
        }
        else if (!resourceTogle.isOn)
        {
            map.VGOToggleGroupVisibility(0, false);
        }

        else if (resourceTogle.isOn)
        {
            map.VGOToggleGroupVisibility(0, true);

            // State.GetResourceIcons()[k].GetComponent<SpriteRenderer>().enabled = true;
            // State.GetResourceIcons()[k].SetActive(true);
        }



        // Instantiate the sprite, face it to up and position it into the map
        //goldIcon.transform.localRotation = Quaternion.Euler(90, 180, 180);
        //goldIcon.transform.localScale = Misc.Vector3one * 1f;
        // GameObject star = Instantiate(Resources.Load<GameObject>("Sprites/StarSprite"));
    }
예제 #5
0
 public DeckDataItem NewDeckItem(string Name, DeckEra era, DeckType type, string DeckLocationName, string DeckLocationContinent, string DeckType, string deckFlag)
 {
     return(new DeckDataItem()
     {
         CurrentDeploymentScore = 0,
         DeckDestination = new Vector2(),
         DeckName = Name,
         DeckTimeEra = era,
         DeckType = type,
         DeckCurrentWorldLocation = map.GetProvince(DeckLocationName, DeckLocationContinent).center,
         //DeckIcon = DeckType,
         //DisplayDeckNameCountryFlag = deckFlag,
         UnitDeckRank = DeckRank.Rank0,
         //UnitDeckRankIcon = DeckIconName(DeckRank.Rank0),
         MaxDeploymentScore = 0
     });
 }