Exemplo n.º 1
0
    public void RemoveCompletedUnitFromInProgress(UnitBlueprint unit, City city)
    {
        if (!city || unit == null || !cityProdItemDict.ContainsKey(city))
        {
            return;
        }

        GameObject unitToDestroy = null;

        if (cityUBAssignedDict[city].Contains(unit))
        {
            cityUBAssignedDict[city].Remove(unit);
        }
        else
        {
            return;
        }

        foreach (GameObject prodItem in cityProdItemDict[city])
        {
            if (prodItem != null && prodItem.GetComponent <CityProductionItem>().UnitBlueprint == unit)
            {
                cityProdItemDict[city].Remove(prodItem);
                unitToDestroy = prodItem;
                break;
            }
        }

        if (unitToDestroy != null)
        {
            cityProdItemDict[city].Remove(unitToDestroy);
            Destroy(unitToDestroy);
        }
    }
Exemplo n.º 2
0
    void Start()
    {
        unit_blueprint = GameObject.Find("DesignPlatform/Unit").GetComponent <UnitBlueprint>();
        self_button    = GetComponent <Button>();
        sp             = Resources.LoadAll <Sprite>("Image/LayerButtonImage");
        self_image     = GetComponent <Image>();

        foreach (Transform t in GetComponentInChildren <Transform>())
        {
            if (t.name == "ButtonName")
            {
                save_button_text = t.GetComponent <Text>();
            }
            else if (t.name == "SaveLoadingAnim")
            {
                loading_anim = t.gameObject;
            }
            else if (t.name == "WarningIcon")
            {
                warning_icon = t.gameObject;
            }
            else if (t.name == "SuccessIcon")
            {
                success_icon = t.gameObject;
            }
        }

        self_image.sprite = sp[3];
        loading_anim.SetActive(false);
        warning_icon.SetActive(false);
        success_icon.SetActive(false);
        ChangeColorByUnitLegal();
        //CheckUnitLegalToSetButton();
    }
Exemplo n.º 3
0
        static bool Basketball(Faction upsFaction)
        {
            var database = LandfallUnitDatabase.GetDatabase();
            //添加一个单位
            var customUnitBase = FindBluePrintByName("Stoner");
            var newUnit        = new UnitBlueprint(customUnitBase);

            newUnit.Entity.Name = "TestUnit";
            upsFaction.Units    = new UnitBlueprint[] { newUnit };
            database.AddUnitWithID(newUnit);
            //定制石头
            //使用巨石为模板实例化一个篮球
            var prefabRoot = new GameObject("PrefabRoot");

            prefabRoot.transform.position = Vector3.zero;
            var basketballWeapon = GameObject.Instantiate(customUnitBase.RightWeapon, prefabRoot.transform);

            //basketballWeapon.SetActive(false);
            basketballWeapon.name = "Thrower_Basketball";
            basketballWeapon.transform.position = new Vector3(0, -100, 0);
            var basketballArmor = GameObject.Instantiate(customUnitBase.RightWeapon.GetComponent <RangeWeapon>().objectToSpawn, prefabRoot.transform);

            //var basketballArmor = GameObject.CreatePrimitive(PrimitiveType.Sphere);
            basketballArmor.transform.parent = prefabRoot.transform;
            //basketballArmor.SetActive(false);
            basketballArmor.name = "B_Basketball";
            //basketballArmor.transform.position = new Vector3(0, -100, 0);
            //加载网格
            var basketballModel = ab.LoadAsset <GameObject>("Basketball");

            if (basketballModel == null)
            {
                modeEntry.Logger.Log("未能正确加载预制体");
                return(false);
            }
            //替换mesh
            var rock1 = basketballWeapon.transform.Find("rock");

            rock1.GetComponent <MeshFilter>().mesh        = basketballModel.GetComponent <MeshFilter>().mesh;
            rock1.GetComponent <MeshRenderer>().materials = basketballModel.GetComponent <MeshRenderer>().materials;
            //
            var rock2 = basketballArmor.transform.Find("rock");

            rock2.GetComponent <MeshFilter>().mesh        = basketballModel.GetComponent <MeshFilter>().mesh;
            rock2.GetComponent <MeshRenderer>().materials = basketballModel.GetComponent <MeshRenderer>().materials;
            GameObject.Destroy(rock2.GetComponent <MeshCollider>());
            rock2.gameObject.AddComponent <SphereCollider>().radius = 0.005565071f;
            //防止销毁
            GameObject.DontDestroyOnLoad(prefabRoot);
            var remover = basketballArmor.GetComponent <RemoveAfterSeconds>();

            basketballArmor.AddComponent <RemoveAdder>().Init(remover);
            GameObject.Destroy(remover);
            //GameObject.Destroy(basketballArmor.GetComponent<RemoveAfterSeconds>());
            newUnit.RightWeapon = basketballWeapon;
            basketballWeapon.GetComponent <RangeWeapon>().objectToSpawn = basketballArmor;
            //
            modeEntry.Logger.Log("添加单位 " + newUnit.Entity.Name + " 到派系 " + upsFaction.Entity.Name);
            return(true);
        }
Exemplo n.º 4
0
    void Start()
    {
        self_AS = GetComponent <AudioSource>();
        all_ACs = new Dictionary <string, AudioClip>();
        all_ACs.Add("Error", Resources.Load <AudioClip>("AudioClip/Error"));


        unit_blueprint   = GameObject.Find("DesignPlatform/Unit").GetComponent <UnitBlueprint>();
        BB               = GameObject.Find("UICanvasTop/BlueprintButton").GetComponent <BlueprintButton>();
        creat_part_audio = GameObject.Find("AudioClickButton01").GetComponent <AudioSource>();

        UI_canvas_base        = GameObject.Find("UICanvasBase").transform as RectTransform;
        part_interface_top    = GameObject.Find("UICanvasTop/PartInterface").transform as RectTransform;
        part_interface_ground = GameObject.Find("UICanvasBase/PartInterfaceGround").transform as RectTransform;
        part_interface        = GameObject.Find("UICanvasBase/PartInterfaceGround/PartInterfaceBackGround/PartInterface").transform as RectTransform;
        part_interface_middle = GameObject.Find("UICanvasMiddle/PartInterfaceMiddle").transform as RectTransform;

        all_part_buttons     = new List <PartButton>();
        all_layer_button     = new List <LayerButton>();
        power_part_buttons   = new List <PartButton>();
        leg_part_buttons     = new List <PartButton>();
        control_part_buttons = new List <PartButton>();
        equip_part_buttons   = new List <PartButton>();
        module_part_buttons  = new List <PartButton>();
        Transform LB_temp = GameObject.Find("UICanvasTop/PartInterfaceBottomBar/PartsLayerToogleGroup").transform;

        foreach (var lb in LB_temp.GetComponentsInChildren <LayerButton>())
        {
            all_layer_button.Add(lb);
        }
        foreach (var temp in part_interface.GetComponentsInChildren <PartButton>())
        {
            all_part_buttons.Add(temp);
            temp.Init();//手动初始化

            switch ((int)temp.part_type)
            {
            case 0:
                power_part_buttons.Add(temp);
                break;

            case 1:
                leg_part_buttons.Add(temp);
                break;

            case 2:
                control_part_buttons.Add(temp);
                break;

            case 3:
                equip_part_buttons.Add(temp);
                break;
            }
        }

        ToolClosePartInterface();
    }
Exemplo n.º 5
0
        public override bool CanPlace(UnitBlueprint unitToSpawn, Team team, ref Vector3 position)
        {
            bool isServer = SocketConnection.GetIsServer();

            return(base.CanPlace(unitToSpawn, team, ref position) &&
                   ((isServer && !SocketConnection.getTcpClient().Connected) ? true :
                    (GetTeamAreaAtPosition(position) == (isServer ? Team.Red : Team.Blue) && !SocketConnection.gameStarted)));
            // Make sure that each client can only place on their position if it's connected
        }
Exemplo n.º 6
0
 public void SelectTile(FloorTiles tile)
 {
     if (selectedTile == tile)
     {
         DeselectTile();
         return;
     }
     selectedTile = tile;
     unitToCreate = null;
 }
Exemplo n.º 7
0
 void Start()
 {
     main_camera          = GetComponent <Camera>();
     fov_start            = main_camera.fieldOfView;
     offset2point_default = transform.position - rotation_point.position;
     offset2point_default_distance_sqr = offset2point_default.sqrMagnitude;
     offset2point_default_distance     = offset2point_default.magnitude;
     unit_blueprint = GameObject.Find("DesignPlatform/Unit").GetComponent <UnitBlueprint>();
     //Debug.Log(offset2point_default_distance_sqr);
 }
Exemplo n.º 8
0
 public new void PlaceUnit(UnitBlueprint blueprint, Team team, Vector3 position, bool costsBudget = true)
 {
     orig_PlaceUnit(blueprint, team, position, costsBudget);
     if (costsBudget) // Don't send the unit when it's placed by the resetter
     {
         SocketConnection.SetCulture();
         SocketConnection.WriteToOpponent("SPAWNUNIT|" + blueprint.Entity.ID + "|" + team.ToString() +
                                          "|" + position.ToString("F5"));
         // Send a spawn command
     }
 }
Exemplo n.º 9
0
    static void LoadUnitBlueprints()
    {
        UnitBlueprint ub;
        int           id = 0;

        ub = new UnitBlueprint(id, "Settler");
        units.Add(id++, ub);

        ub = new UnitBlueprint(id, "Warrior");
        units.Add(id++, ub);
    }
Exemplo n.º 10
0
    void Start()
    {
        self               = this;
        unit_blueprint     = GameObject.Find("DesignPlatform/Unit").GetComponent <UnitBlueprint>();
        module_button_dict = new Dictionary <int, ModuleButton>();
        content            = GameObject.Find("UICanvasBase/ModuleInterface/Scroll View/Viewport/Content").transform;
        module_interface   = GameObject.Find("UICanvasBase/ModuleInterface").transform;

        LoadConfigurationTableAtSceneStart();
        CloseModuleInterface();
    }
Exemplo n.º 11
0
    void Start()
    {
        unit_blueprint = GameObject.Find("DesignPlatform/Unit").GetComponent <UnitBlueprint>();

        systemmask = GameObject.Find("UICanvasTop/SystemMask");
        warining_ReturnGameStartSceneButton = GameObject.Find("UICanvasTop/SystemMask/Menu/ReturnGameStartSceneWarning");
        warining_QuitGameButton             = GameObject.Find("UICanvasTop/SystemMask/Menu/QuitGameWarning");

        warining_ReturnGameStartSceneButton.SetActive(false);
        warining_QuitGameButton.SetActive(false);
        systemmask.SetActive(false);
        unit_blueprint.menu_open = false;
    }
Exemplo n.º 12
0
    public void Init()
    {
        link_info = new int[2] {
            -999, -999
        };                                    //连接的零件ID和连接的节点的ID
        unit_blueprint = GameObject.Find("DesignPlatform/Unit").GetComponent <UnitBlueprint>();
        //找到自己归属于哪个零件:
        Transform search_parent = transform;//开始搜寻时将搜寻起点设置为自己

        while (search_parent.tag != "Part")
        {
            search_parent = search_parent.transform.parent;
        }
        self_root_part = search_parent.GetComponent <Part>();
    }
Exemplo n.º 13
0
    public void OnClick()
    {
        //todo - get current city production

        if (thisBuildingJob == null)
        {
            BuildingJob buildingJob = null;
            if (BuildingBlueprint != null)
            {
                buildingJob = new BuildingJob(
                    BuildingBlueprint.name,
                    BuildingBlueprint.productionCost,
                    0,
                    () => {
                    BuildingBlueprint.OnBuildingComplete(MyCity);
                    Destroy(gameObject);
                },
                    null
                    );
            }
            else if (UnitBlueprint != null)
            {
                buildingJob = new BuildingJob(
                    UnitBlueprint.name,
                    UnitBlueprint.productionCost,
                    0,
                    () => {
                    UnitBlueprint.OnUnitComplete(MyCity);
                    MyCityScreen.RemoveCompletedUnitFromInProgress(UnitBlueprint, MyCity);
                },
                    null
                    );
            }

            thisBuildingJob = buildingJob;
        }


        MyCity.SetCurrentBuildingJob(thisBuildingJob);

        if (MyCityScreen)
        {
            MyCityScreen.UpdateCurrentProductionText();
        }
    }
Exemplo n.º 14
0
    public virtual void Init()
    {
        animator          = GetComponent <Animator>();
        canvas_base       = GameObject.Find("UICanvasBase").GetComponent <GraphicRaycaster>();
        small_icon_canvas = GameObject.Find("SmallIconCanvas").transform;
        unit_blueprint    = GameObject.Find("DesignPlatform/Unit").GetComponent <UnitBlueprint>();
        link_audio        = unit_blueprint.GetComponent <AudioSource>();
        #region UI初始化
        overstep_UI_name      = "Warning";
        overlap_UI_name       = "Overlap";
        inair_UI_name         = "Inair";
        energy_supply_UI_name = "NoPower";

        energy_supply_UI   = Instantiate(Resources.Load <RectTransform>("UI/" + energy_supply_UI_name).GetComponent <Image>(), small_icon_canvas);
        energy_supply_text = energy_supply_UI.GetComponentInChildren <Text>();
        all_UI.Add(energy_supply_UI);

        energy_supply_UI.enabled   = false;
        energy_supply_text.enabled = false;
        #endregion
    }
Exemplo n.º 15
0
        static bool ReverseMaceSpinner(Faction upsFaction)
        {
            var database = LandfallUnitDatabase.GetDatabase();
            //添加一个单位
            var customUnitBase = FindBluePrintByName("Brawler");

            if (customUnitBase == null)
            {
                return(false);
            }
            var newUnit = new UnitBlueprint(customUnitBase);

            newUnit.Entity.Name = "TestUnit";
            upsFaction.Units    = new UnitBlueprint[] { newUnit };
            database.AddUnitWithID(newUnit);

            //加载网格
            var jingGaiModel = ab.LoadAsset <GameObject>("JingGai");

            if (jingGaiModel == null)
            {
                modeEntry.Logger.Log("未能正确加载预制体");
                return(false);
            }

            //拿到盾牌预制体
            var prefabRoot = new GameObject("PrefabRoot");

            GameObject.DontDestroyOnLoad(prefabRoot);
            prefabRoot.transform.position = Vector3.zero;
            var dunPaiWeapon = GameObject.Instantiate(newUnit.LeftWeapon, prefabRoot.transform);

            dunPaiWeapon.transform.Find("CP_Viking_Shield001").gameObject.SetActive(false);
            //放到盾牌预制体之下
            var jingGai = GameObject.Instantiate(jingGaiModel, dunPaiWeapon.transform);

            jingGai.transform.localScale = Vector3.one;
            newUnit.LeftWeapon           = dunPaiWeapon;
            return(true);
        }
Exemplo n.º 16
0
    public bool Init(GameObject _UIunit)
    {
        unit_blueprint = GameObject.Find("DesignPlatform/Unit").GetComponent <UnitBlueprint>();
        foreach (Transform t in GetComponentsInChildren <Transform>())
        {
            if (t.name == "HoverImage")
            {
                hover_image = t.GetComponent <Image>();
            }
            else if (t.name == "BanImage")
            {
                ban_image = t.GetComponent <Image>();
            }
            else if (t.name == "UnitName")
            {
                name_text = t.GetComponent <Text>();
            }
            else if (t.name == "iIcon")
            {
                //self_i_icon = t.GetComponent<iIcon>();
            }
        }

        self_RT = transform as RectTransform;
        string unit_name = _UIunit.name;

        name           = unit_name + "Button";
        name_text.text = unit_name;
        UIunit         = _UIunit;

        //找到 UnitInterfaceContent :
        //content = GameObject.Find("UICanvasBase/UnitInterfaceGround/UnitInterfaceBackGround/UnitInterface/Viewport/UnitInterfaceContent").transform;

        UIunit.transform.position   = transform.position;
        UIunit.transform.localScale = new Vector3(0.35f, 0.35f, 0.35f);
        UIunit.gameObject.AddComponent <UIPartBehaviour>();
        hover_image.enabled = false;

        return(true);
    }
Exemplo n.º 17
0
    RectTransform unit_interface_middle; //单位菜单遮挡用外框
    #endregion

    void Start()
    {
        self       = this;
        sp         = Resources.LoadAll <Sprite>("Image/LayerButtonImage");
        self_image = GetComponent <Image>();

        unit_blueprint        = GameObject.Find("DesignPlatform/Unit").GetComponent <UnitBlueprint>();
        UIunit_group          = GameObject.Find("UnitPart").transform;
        BC                    = GameObject.Find("ButtonController").GetComponent <ButtonController>();
        content               = GameObject.Find("UICanvasBase/UnitInterfaceGround/UnitInterfaceBackGround/UnitInterface/Viewport/UnitInterfaceContent").transform as RectTransform;
        UI_canvas_base        = GameObject.Find("UICanvasBase").transform as RectTransform;
        unit_interface_top    = GameObject.Find("UICanvasTop/UnitInterface").transform as RectTransform;
        unit_interface_ground = GameObject.Find("UICanvasBase/UnitInterfaceGround").transform as RectTransform;
        unit_interface        = GameObject.Find("UICanvasBase/UnitInterfaceGround/UnitInterfaceBackGround/UnitInterface").transform as RectTransform;

        unit_interface_middle = GameObject.Find("UICanvasMiddle/UnitInterfaceMiddle").transform as RectTransform;


        //调用协程加载所有用户数据:
        LoadUserDataAtStart();

        self_image.sprite = sp[0];
    }
Exemplo n.º 18
0
    public void Init()
    {
        part_pos_default = new Vector3(-2.5f, 1.3f, -1f);
        UIpart_camera    = GameObject.Find("UIPartCamera").GetComponent <Camera>();
        UI_camera        = GameObject.Find("UICamera").GetComponent <Camera>();
        canvas           = GameObject.Find("UICanvasBase").transform as RectTransform;
        UIpart_group     = GameObject.Find("UIPart").transform;
        UIpart_offset    = new Vector3(0, 0, -0.2f);
        unit_blueprint   = GameObject.Find("DesignPlatform/Unit").GetComponent <UnitBlueprint>();
        UI_canvas_top    = GameObject.Find("UICanvasTop").transform as RectTransform;
        self_screen_pos  = Camera.main.WorldToScreenPoint(transform.position);

        foreach (Transform t in GetComponentsInChildren <Transform>())
        {
            if (t.name == "HoverImage")
            {
                hover_image = t.GetComponent <Image>();
            }
            else if (t.name == "BanImage")
            {
                ban_image = t.GetComponent <Image>();
            }
            else if (t.name == "PartName")
            {
                name_text = t.GetComponent <Text>();
            }
            else if (t.name == "iIcon")
            {
                self_i_icon = t.GetComponent <iIcon>();
                self_i_icon.parent_button = this;
            }
        }
        switch ((int)part_type)
        {
        case 0:
            UIpart_prefab       = Instantiate(Resources.Load <GameObject>("UIPart/PowerUIPart/" + UIpart_name), UIpart_group);
            part_particulars_UI = Instantiate(Resources.Load <GameObject>("UI/PartParticulars/PowerPartParticulars"), UI_canvas_top);
            temp_part_prefab    = Instantiate(Resources.Load <GameObject>("Part/PowerPart/" + part_name));
            PowerPart temp_powerpart = temp_part_prefab.GetComponent <PowerPart>();
            name_text.text = temp_powerpart.self_name;
            foreach (RectTransform rt in part_particulars_UI.GetComponentsInChildren <RectTransform>())
            {
                if (rt.name == "Name")
                {
                    rt.GetComponent <Text>().text = temp_powerpart.self_name;
                }
                else if (rt.name == "Power")
                {
                    rt.GetComponent <Text>().text = "能量  +" + temp_powerpart.power_value.ToString();
                }
                else if (rt.name == "Weight")
                {
                    rt.GetComponent <Text>().text = "重量  " + temp_powerpart.weight_value.ToString();
                }
                else if (rt.name == "Durability")
                {
                    rt.GetComponent <Text>().text = "耐久  " + temp_powerpart.durability_value.ToString();
                }
                else if (rt.name == "Specialty")
                {
                    //rt.GetComponent<Text>().text = "特性  " + temp_powerpart.durability_value.ToString();
                }
                else if (rt.name == "NormalDEF")
                {
                    rt.GetComponent <Text>().text = temp_powerpart.normalDEF_value.ToString();
                }
                else if (rt.name == "BlastDEF")
                {
                    rt.GetComponent <Text>().text = temp_powerpart.blastDEF_value.ToString();
                }
                else if (rt.name == "EnergyDEF")
                {
                    rt.GetComponent <Text>().text = temp_powerpart.energyDEF_value.ToString();
                }
                else if (rt.name == "Cost")
                {
                    rt.GetComponent <Text>().text = temp_powerpart.cost.ToString();
                }
            }
            break;

        case 1:
            UIpart_prefab       = Instantiate(Resources.Load <GameObject>("UIPart/MovementUIPart/" + UIpart_name), UIpart_group);
            part_particulars_UI = Instantiate(Resources.Load <GameObject>("UI/PartParticulars/LegPartParticulars"), UI_canvas_top);
            temp_part_prefab    = Instantiate(Resources.Load <GameObject>("Part/MovementPart/LegPart/" + part_name));
            LegPart temp_legpart = temp_part_prefab.GetComponent <LegPart>();
            name_text.text = temp_legpart.self_name;
            foreach (RectTransform rt in part_particulars_UI.GetComponentsInChildren <RectTransform>())
            {
                if (rt.name == "Name")
                {
                    rt.GetComponent <Text>().text = temp_legpart.self_name;
                }
                else if (rt.name == "UsePower")
                {
                    rt.GetComponent <Text>().text = "持续耗能    " + temp_legpart.usepower_value.ToString();
                }
                else if (rt.name == "Load")
                {
                    rt.GetComponent <Text>().text = "最大载重    " + temp_legpart.load_value.ToString();
                }
                else if (rt.name == "Move")
                {
                    rt.GetComponent <Text>().text = "移动力       " + temp_legpart.move_value.ToString();
                }
                else if (rt.name == "Dodge")
                {
                    rt.GetComponent <Text>().text = "灵活性       " + temp_legpart.dodge_value.ToString();
                }
                else if (rt.name == "Durability")
                {
                    rt.GetComponent <Text>().text = "耐久         " + temp_legpart.durability_value.ToString();
                }
                else if (rt.name == "Specialty")
                {
                    if (temp_legpart.specialty.Count == 0)
                    {
                        rt.GetComponent <Text>().text = "";
                    }
                    else
                    {
                        string spec = "";
                        foreach (int sp in temp_legpart.specialty)
                        {
                            switch (sp)
                            {
                            case 0:
                                spec += "闪避叠加  ";
                                break;

                            case 1:
                                spec += "反应装甲  ";
                                break;
                            }
                        }
                        rt.GetComponent <Text>().text = "特性         " + spec;
                    }
                }
                else if (rt.name == "NormalDEF")
                {
                    rt.GetComponent <Text>().text = temp_legpart.normalDEF_value.ToString();
                }
                else if (rt.name == "BlastDEF")
                {
                    rt.GetComponent <Text>().text = temp_legpart.blastDEF_value.ToString();
                }
                else if (rt.name == "EnergyDEF")
                {
                    rt.GetComponent <Text>().text = temp_legpart.energyDEF_value.ToString();
                }
                else if (rt.name == "Cost")
                {
                    rt.GetComponent <Text>().text = temp_legpart.cost.ToString();
                }
            }
            break;

        case 2:
            UIpart_prefab       = Instantiate(Resources.Load <GameObject>("UIPart/ControlUIPart/" + UIpart_name), UIpart_group);
            part_particulars_UI = Instantiate(Resources.Load <GameObject>("UI/PartParticulars/ControlPartParticulars"), UI_canvas_top);
            temp_part_prefab    = Instantiate(Resources.Load <GameObject>("Part/ControlPart/" + part_name));
            ControlPart temp_controlpart = temp_part_prefab.GetComponent <ControlPart>();
            name_text.text = temp_controlpart.self_name;
            foreach (RectTransform rt in part_particulars_UI.GetComponentsInChildren <RectTransform>())
            {
                if (rt.name == "Name")
                {
                    rt.GetComponent <Text>().text = temp_controlpart.self_name;
                }
                else if (rt.name == "UsePower")
                {
                    rt.GetComponent <Text>().text = "持续耗能    " + temp_controlpart.usepower_value.ToString();
                }
                else if (rt.name == "Weight")
                {
                    rt.GetComponent <Text>().text = "重量    " + temp_controlpart.weight_value.ToString();
                }
                else if (rt.name == "Modules")
                {
                    rt.GetComponent <Text>().text = "模块    " + temp_controlpart.modules_value.ToString();
                }
                else if (rt.name == "Durability")
                {
                    rt.GetComponent <Text>().text = "耐久    " + temp_controlpart.durability_value.ToString();
                }
                else if (rt.name == "NormalDEF")
                {
                    rt.GetComponent <Text>().text = temp_controlpart.normalDEF_value.ToString();
                }
                else if (rt.name == "BlastDEF")
                {
                    rt.GetComponent <Text>().text = temp_controlpart.blastDEF_value.ToString();
                }
                else if (rt.name == "EnergyDEF")
                {
                    rt.GetComponent <Text>().text = temp_controlpart.energyDEF_value.ToString();
                }
                else if (rt.name == "Cost")
                {
                    rt.GetComponent <Text>().text = temp_controlpart.cost.ToString();
                }
            }
            break;

        case 3:
            UIpart_prefab       = Instantiate(Resources.Load <GameObject>("UIPart/EquipmentUIPart/" + UIpart_name), UIpart_group);
            part_particulars_UI = Instantiate(Resources.Load <GameObject>("UI/PartParticulars/EquipmentPartParticulars"), UI_canvas_top);
            temp_part_prefab    = Instantiate(Resources.Load <GameObject>("Part/EquipmentPart/" + part_name));
            EquipmentPart temp_equippart = temp_part_prefab.GetComponent <EquipmentPart>();
            name_text.text = temp_equippart.self_name;
            foreach (RectTransform rt in part_particulars_UI.GetComponentsInChildren <RectTransform>())
            {
                if (rt.name == "Name")
                {
                    rt.GetComponent <Text>().text = temp_equippart.self_name;
                }
                else if (rt.name == "PartType")
                {
                    string s1 = "";
                    string s2 = "";


                    switch ((int)temp_equippart.damage_type)
                    {
                    case 0:
                        //normal
                        s1 = "常规武器";
                        break;

                    case 1:
                        //blast
                        s1 = "爆炸武器";
                        break;

                    case 2:
                        //energy
                        s1 = "能量武器";
                        break;
                    }
                    switch ((int)temp_equippart.atk_pattern)
                    {
                    case 0:
                        s2 = "射击";
                        break;

                    case 1:
                        s2 = "飞弹";
                        break;
                    }

                    rt.GetComponent <Text>().text = "装备·" + s1 + "·" + s2;
                }
                else if (rt.name == "UsePower")
                {
                    rt.GetComponent <Text>().text = "持续耗能    " + temp_equippart.usepower_value.ToString();
                }
                else if (rt.name == "EachUsePower")
                {
                    rt.GetComponent <Text>().text = "使用耗能    " + temp_equippart.eachusepower_value.ToString();
                }
                else if (rt.name == "Damage")
                {
                    rt.GetComponent <Text>().text = "伤害             " + temp_equippart.damage.ToString() + " * " + temp_equippart.attack_number.ToString();
                }
                else if (rt.name == "DamageTypeIcon")
                {
                    switch ((int)temp_equippart.damage_type)
                    {
                    case 0:
                        //normal
                        rt.GetComponent <Image>().sprite = Resources.LoadAll <Sprite>("Icon/DamageTypeIcons")[0];
                        break;

                    case 1:
                        //blast
                        rt.GetComponent <Image>().sprite = Resources.LoadAll <Sprite>("Icon/DamageTypeIcons")[1];
                        break;

                    case 2:
                        //energy
                        rt.GetComponent <Image>().sprite = Resources.LoadAll <Sprite>("Icon/DamageTypeIcons")[2];
                        break;
                    }
                }
                else if (rt.name == "Range")
                {
                    rt.GetComponent <Text>().text = "射程          " + temp_equippart.range_value.ToString();
                }
                else if (rt.name == "Ammo")
                {
                    string one;
                    string two;
                    if (temp_equippart.ammo_value == -999)
                    {
                        one = "∞";
                    }
                    else
                    {
                        one = temp_equippart.ammo_value.ToString();
                    }
                    if (temp_equippart.magazine_value == -999)
                    {
                        two = "∞";
                    }
                    else
                    {
                        two = temp_equippart.magazine_value.ToString();
                    }
                    rt.GetComponent <Text>().text = "弹药          " + one + "/" + two;
                }
                else if (rt.name == "Specialty")
                {
                    if (temp_equippart.specialty.Count == 0)
                    {
                        rt.GetComponent <Text>().text = "";
                    }
                    else
                    {
                        string spec = "";
                        foreach (int sp in temp_equippart.specialty)
                        {
                            switch (sp)
                            {
                            case 0:
                                spec += "连射  ";
                                break;

                            case 1:
                                spec += "  ";
                                break;
                            }
                        }
                        rt.GetComponent <Text>().text = "特性         " + spec;
                    }
                }
                else if (rt.name == "Weight")
                {
                    rt.GetComponent <Text>().text = "重量          " + temp_equippart.weight_value.ToString();
                }
                else if (rt.name == "Durability")
                {
                    rt.GetComponent <Text>().text = "耐久          " + temp_equippart.durability_value.ToString();
                }
                else if (rt.name == "Tag")
                {
                    if (temp_equippart.symmetry)
                    {
                        rt.GetComponentInChildren <Text>().text = "对称";
                    }
                    else
                    {
                        rt.GetComponentInChildren <Text>().text = "多方向";
                    }
                }
                else if (rt.name == "NormalDEF")
                {
                    rt.GetComponent <Text>().text = temp_equippart.normalDEF_value.ToString();
                }
                else if (rt.name == "BlastDEF")
                {
                    rt.GetComponent <Text>().text = temp_equippart.blastDEF_value.ToString();
                }
                else if (rt.name == "EnergyDEF")
                {
                    rt.GetComponent <Text>().text = temp_equippart.energyDEF_value.ToString();
                }
                else if (rt.name == "Cost")
                {
                    rt.GetComponent <Text>().text = temp_equippart.cost.ToString();
                }
            }
            break;
        }

        Destroy(temp_part_prefab);            //销毁临时零件
        part_particulars_UI.GetComponent <PartParticulars>().parent_button = this;
        part_particulars_UI.SetActive(false); //关闭零件详情页
    }
Exemplo n.º 19
0
 public static ICommand Command(GameState game, Tile <TileInfo> tile, UnitBlueprint blueprint)
 => new SpawnEnemy(game, tile, blueprint);
Exemplo n.º 20
0
 private SpawnEnemy(GameState game, Tile <TileInfo> tile, UnitBlueprint blueprint)
 {
     this.game      = game;
     this.tile      = tile;
     this.blueprint = blueprint;
 }
Exemplo n.º 21
0
 void Start()
 {
     unit_blueprint = GameObject.Find("DesignPlatform/Unit").GetComponent <UnitBlueprint>();
 }
Exemplo n.º 22
0
        private void OnGUI()
        {
            if (styles == null)
            {
                styles = new GUIStyle[]
                {
                    new GUIStyle(GUI.skin.textField)
                    {
                        fontSize = (int)(0.02f * (float)Screen.height)
                    },
                    new GUIStyle(GUI.skin.box)
                    {
                        fontSize = (int)(0.04f * (float)Screen.height)
                    },
                    new GUIStyle(GUI.skin.button)
                    {
                        fontSize = (int)(0.02f * (float)Screen.height)
                    },
                    new GUIStyle(GUI.skin.label)
                    {
                        fontSize = (int)(0.014f * (float)Screen.height)
                    },
                    new GUIStyle(GUI.skin.box)
                    {
                        fontSize = (int)(0.025f * (float)Screen.height)
                    }
                };
                backgroundColor = new Color32(51, 100, 51, 255);
                background      = new Texture2D(1, 1);
                background.SetPixel(0, 0, new Color(1, 1, 1, 1));
                background.Apply();
            }
            else
            {
                styles[0].fontSize          = (int)(0.02f * (float)Screen.height);
                styles[1].fontSize          = (int)(0.04f * (float)Screen.height);
                styles[2].fontSize          = (int)(0.02f * (float)Screen.height);
                styles[3].fontSize          = (int)(0.014f * (float)Screen.height);
                styles[4].fontSize          = (int)(0.025f * (float)Screen.height);
                styles[1].normal.background = background;
                styles[4].normal.background = background;
                GUI.backgroundColor         = backgroundColor;
            }

            GameModeService  gameModeService = ServiceLocator.GetService <GameModeService>();
            GameStateManager gameModeManager = ServiceLocator.GetService <GameStateManager>();
            PlacementUI      pUI             = FindObjectOfType <PlacementUI>();
            Faction          selectedFaction = null;

            if (pUI)
            {
                selectedFaction = (Faction)pUI.GetField("m_selectedFaction");
            }
            if (gameModeService && (gameModeManager.GameState == GameState.PlacementState) && (pUI) && selectedFaction && (selectedFaction.Entity.Name == faction.Entity.Name || loadedFactions.ContainsKey(((Faction)pUI.GetField("m_selectedFaction")).Entity.GUID)) && enableGUI)
            {
                UnitPlacementBrush brush        = (UnitPlacementBrush)pUI.GetField("m_unitPlacementBrush");
                UnitBlueprint      selectedUnit = brush.UnitToSpawn;
                if (!canvas)
                {
                    canvas = new GameObject("WebTabsCanvas");
                }
                canvas.SetActive(true);
                Canvas gameCanvas = FindObjectOfType <Canvas>();
                if (gameCanvas)
                {
                    canvas.transform.SetParent(gameCanvas.transform);
                    canvas.FetchComponent <EventSystem>();
                    canvas.FetchComponent <Image>().color = new Color32(4, 36, 20, 255);
                    RectTransform rt = canvas.FetchComponent <RectTransform>();
                    rt.pivot            = new Vector2(0.5f, 0.5f);
                    rt.anchorMax        = new Vector2(0.99f, 0.935f);
                    rt.anchorMin        = new Vector2(0.79f, 0.41f);
                    rt.anchoredPosition = Vector2.zero;
                    rt.sizeDelta        = new Vector2(1, 1);
                }
                GUI.Box(new Rect(0.79f * (float)Screen.width, 0.06f * (float)Screen.height, 0.2f * (float)Screen.width, 0.15f * (float)Screen.height), "WebTabs", styles[1]);

                GUI.Label(new Rect(0.81f * (float)Screen.width, 0.105f * (float)Screen.height, 0.05f * (float)Screen.width, 0.04f * (float)Screen.height), "Unit Key:", styles[3]);
                unitID = GUI.TextField(new Rect(0.858f * (float)Screen.width, 0.108f * (float)Screen.height, 0.05f * (float)Screen.width, 0.025f * (float)Screen.height), unitID, styles[0]).ToLower();
                if (unitID.Length > 8)
                {
                    unitID = unitID.Substring(0, 8);
                }

                if (GUI.Button(new Rect(0.82f * (float)Screen.width, 0.14f * (float)Screen.height, 0.15f * (float)Screen.width, 0.02f * (float)Screen.height), "Get Unit", styles[2]))
                {
                    GetUnits(new string[] { unitID });
                }

                if (GUI.Button(new Rect(0.82f * (float)Screen.width, 0.16f * (float)Screen.height, 0.15f * (float)Screen.width, 0.02f * (float)Screen.height), ((selectedUnit && Array.Exists(faction.Units, element => element == selectedUnit)) ? "Delete '" + selectedUnit.Entity.Name + "'" : "No unit selected"), styles[2]) && (selectedUnit && Array.Exists(faction.Units, element => element == selectedUnit) && selectedFaction == faction))
                {
                    output = "Deleting '" + selectedUnit.Entity.Name + "'...\n";
                    string deleteID = loadedUnits[selectedUnit.Entity.GUID];
                    deletedUnits[deleteID] = selectedUnit;
                    loadedUnits.Remove(selectedUnit.Entity.GUID);
                    UFunctions.RemoveUnitFromFaction(selectedUnit, faction);
                    pUI.RedrawFactionUnits(faction);
                    brush.ClearBrushUnit();
                    foreach (Unit unit in (from Unit unit in FindObjectsOfType <Unit>() where unit.unitBlueprint == selectedUnit select unit))
                    {
                        brush.RemoveUnitInternal(unit, unit.Team);
                    }
                    output += "Deleted unit successfully!";
                }
                GUI.Box(new Rect(0.79f * (float)Screen.width, 0.25f * (float)Screen.height, 0.2f * (float)Screen.width, 0.15f * (float)Screen.height), "Factions", styles[4]);

                GUI.Label(new Rect(0.81f * (float)Screen.width, 0.295f * (float)Screen.height, 0.05f * (float)Screen.width, 0.04f * (float)Screen.height), "Faction Key:", styles[3]);
                factionID = GUI.TextField(new Rect(0.858f * (float)Screen.width, 0.298f * (float)Screen.height, 0.05f * (float)Screen.width, 0.025f * (float)Screen.height), factionID, styles[0]).ToLower();
                if (factionID.Length > 8)
                {
                    factionID = factionID.Substring(0, 8);
                }

                if (GUI.Button(new Rect(0.82f * (float)Screen.width, 0.33f * (float)Screen.height, 0.15f * (float)Screen.width, 0.02f * (float)Screen.height), "Get Faction", styles[2]))
                {
                    GetFactions(new string[] { factionID });
                }

                if (GUI.Button(new Rect(0.82f * (float)Screen.width, 0.35f * (float)Screen.height, 0.15f * (float)Screen.width, 0.02f * (float)Screen.height), ((selectedFaction && selectedFaction != faction) ? "Delete '" + selectedFaction.Entity.Name + "'" : "No faction selected"), styles[2]) && (selectedFaction) && selectedFaction != faction)
                {
                    output = "Deleting '" + selectedFaction.Entity.Name + "'...\n";
                    string deleteID = loadedFactions[selectedFaction.Entity.GUID];
                    deletedFactions[deleteID] = selectedFaction;
                    loadedFactions.Remove(selectedFaction.Entity.GUID);
                    selectedFaction.m_displayFaction = false;
                    pUI.SelectFaction();
                    pUI.RedrawFactions();
                    brush.ClearBrushUnit();
                    output += "Deleted faction successfully!";
                }

                GUI.Box(new Rect(0.79f * (float)Screen.width, 0.44f * (float)Screen.height, 0.2f * (float)Screen.width, 0.07f * (float)Screen.height), "Save All Data", styles[4]);

                if (GUI.Button(new Rect(0.82f * (float)Screen.width, 0.48f * (float)Screen.height, 0.15f * (float)Screen.width, 0.02f * (float)Screen.height), "Save", styles[2]))
                {
                    SaveData();
                }

                GUI.Box(new Rect(0.79f * (float)Screen.width, 0.53f * (float)Screen.height, 0.2f * (float)Screen.width, 0.07f * (float)Screen.height), "Console", styles[4]);

                GUI.TextField(new Rect(0.81f * (float)Screen.width, 0.56f * (float)Screen.height, 0.2f * (float)Screen.width, 0.04f * (float)Screen.height), output, styles[3]);
            }
            else if (canvas)
            {
                canvas.SetActive(false);
            }
        }
Exemplo n.º 23
0
 public extern void orig_PlaceUnit(UnitBlueprint blueprint, Team team, Vector3 position, bool costsBudget);
Exemplo n.º 24
0
 public void SelectUnitToCreate(UnitBlueprint unit)
 {
     unitToCreate = unit;
 }
Exemplo n.º 25
0
    void Start()
    {
        _unit_info     = this;
        self_AS        = GetComponent <AudioSource>();
        unit_blueprint = GameObject.Find("DesignPlatform/Unit").GetComponent <UnitBlueprint>();
        rotation_point = GameObject.Find("Rotation point").transform;
        all_audioclip  = new Dictionary <string, AudioClip>();
        all_audioclip.Add("PowerDown", Resources.Load <AudioClip>("AudioClip/PowerDown"));
        all_audioclip.Add("PowerUp", Resources.Load <AudioClip>("AudioClip/PowerUp"));
        WarningColor   = Resources.LoadAll <Sprite>("Icon/WarningColor");
        modules        = new List <RectTransform>();
        modules_script = new List <ModuleButtonInUnitInfoInterface>();
        foreach (Transform t in GetComponentsInChildren <Transform>())
        {
            if (t.name == "UnitName")
            {
                unit_name_text = t.GetComponent <Text>();
                foreach (Transform tt in unit_name_text.GetComponentsInChildren <Transform>())
                {
                    if (tt.name == "InputWarningUI")
                    {
                        input_warning_UI = tt.GetComponent <Image>();
                    }
                }
            }
            else if (t.name == "PowerPartError")
            {
                power_part_UI     = t.GetComponent <Image>();
                power_part_UItext = power_part_UI.GetComponentInChildren <Text>();
            }
            else if (t.name == "CtrlPartError")
            {
                ctrl_part_UI     = t.GetComponent <Image>();
                ctrl_part_UItext = ctrl_part_UI.GetComponentInChildren <Text>();
            }
            else if (t.name == "MovementPartError")
            {
                movement_part_UI     = t.GetComponent <Image>();
                movement_part_UItext = movement_part_UI.GetComponentInChildren <Text>();
            }
            else if (t.name == "ModuleError")
            {
                module_error = t.gameObject;
            }
            else if (t.name == "Power")
            {
                power = t.GetComponent <Text>();
                foreach (Transform tt in power.GetComponentsInChildren <Transform>())
                {
                    if (tt.name == "PowerValue")
                    {
                        power_text = tt.GetComponent <Text>();
                    }
                }
            }
            else if (t.name == "Movement")
            {
                movement = t.GetComponent <Text>();
                foreach (Transform tt in movement.GetComponentsInChildren <Transform>())
                {
                    if (tt.name == "MovementValue")
                    {
                        movement_text = tt.GetComponent <Text>();
                    }
                }
            }
            else if (t.name == "Weight")
            {
                weight = t.GetComponent <Text>();
                foreach (Transform tt in weight.GetComponentsInChildren <Transform>())
                {
                    if (tt.name == "WeightValue")
                    {
                        weight_text = tt.GetComponent <Text>();
                    }
                }
            }
            else if (t.name == "Dodge")
            {
                dodge = t.GetComponent <Text>();
                foreach (Transform tt in dodge.GetComponentsInChildren <Transform>())
                {
                    if (tt.name == "DodgeValue")
                    {
                        dodge_text = tt.GetComponent <Text>();
                    }
                }
            }
            else if (t.name == "Cost")
            {
                foreach (Transform tt in t.GetComponentsInChildren <Transform>())
                {
                    if (tt.name == "CostValue")
                    {
                        cost_text = tt.GetComponent <Text>();
                    }
                }
            }
            else if (t.name == "ModulesGroup")
            {
                foreach (Transform tt in t.GetComponentsInChildren <Transform>())
                {
                    if (tt.tag == "ModuleButton")
                    {
                        modules.Add(tt as RectTransform);
                        tt.GetComponent <ModuleButtonInUnitInfoInterface>().Init();
                        modules_script.Add(tt.GetComponent <ModuleButtonInUnitInfoInterface>());
                    }
                }
            }
        }

        compare4dodge = new List <int>();

        CountPowerValue();
        SetPowerValueUI();
        CountWeightValue();
        SetWeightValueUI();
        CountMovementValue();
        SetMovementValueUI();
        CountDodgeValue();
        SetDodgeValueUI();
        CountCostValue();
        SetCostValue();
        CountModulesCount();
        SetModulesCount();
        CountModuleNumber();
        initover = true;
    }
Exemplo n.º 26
0
        public static void Tick()     // A thread safe repeating method
        {
            if (Time.time > waitTime) // Wait until the interval has passed (~60tps)
            {
                waitTime += interval;
                SocketConnection.SetCulture();

                if (SocketConnection.getUIClient().Connected)
                {
                    ScreenshareSender.SetWinHandle(); // Send the unity window handle for receiving images
                }

                if (SocketConnection.switchScene)
                {
                    SocketConnection.switchScene = false;
                    TABSSceneManager.LoadScene(SocketConnection.newScene, true); // Instantly load the new scene
                }

                if (SocketConnection.switchMap)
                {
                    //SocketConnection.WriteToUI("SHOWMSG|Loading a map!"); // Debug
                    SocketConnection.switchMap = false;
                    CampaignPlayerDataHolder.StartedPlayingSandbox();          // Change the game state
                    TABSSceneManager.LoadMap(GetMap(SocketConnection.newMap)); // Load the new map
                }

                if (SocketConnection.updateBudget) // Refresh the UI's budget
                {
                    SocketConnection.updateBudget = false;
                    UpdateUIBudget();
                }


                while (SocketConnection.tickCommands.TryDequeue(out string newData))
                {
                    if (newData.StartsWith("SPAWNUNIT"))
                    {
                        string[] split   = newData.Split('|');
                        string   entName = split[1];
                        Team     team    = (Team)Enum.Parse(typeof(Team), split[2]);
                        Vector3  pos     = StrToVec3(split[3]);

                        UnitBlueprint blueprint = GetUnitBlueprint(entName);
                        GetBrushBehaviorOfUnitBrush(GameObject.FindObjectOfType <UnitBrush>()).Place(blueprint, team, pos); // Add the unit with the brush

                        ServiceLocator.GetService <BattleBudget>().SpendAmount(team, (int)blueprint.UnitCost);              // Update the budget
                        UpdateUIBudget();
                    }
                    else if (newData.StartsWith("REMOVEUNIT"))
                    {
                        string[] split = newData.Split('|');
                        Vector3  pos   = StrToVec3(split[1]);
                        Team     team  = (Team)Enum.Parse(typeof(Team), split[2]);

                        Unit unit = FindClosestUnit(pos); // Get the nearest unit of the pos
                        if (unit != null && unit.Team == team)
                        {
                            GetBrushBehaviorOfUnitBrush(GameObject.FindObjectOfType <UnitBrush>()).Remove(unit, team);       // Remove the unit with the brush

                            ServiceLocator.GetService <BattleBudget>().ReturnAmount(team, (int)unit.unitBlueprint.UnitCost); // Update the budget
                            UpdateUIBudget();
                        }
                    }
                    else if (newData.StartsWith("CLEAR"))
                    {
                        bool        red  = bool.Parse(newData.Split('|')[1]);
                        Team        team = red ? Team.Red : Team.Blue;
                        PlacementUI pui  = GameObject.FindObjectOfType <PlacementUI>(); // Get the placement UI

                        // Clear the right area without triggering an echo
                        UnitLayoutManager.ClearTeam(team);
                        GetClearButtonDelegate(pui)(team);
                    }
                    else if (newData.StartsWith("AUDIO"))
                    {
                        string[] split = newData.Split('|');

                        string  soundRef = split[1];
                        float   volMulti = float.Parse(split[2]);
                        Vector3 relPos   = StrToVec3(split[3]);
                        SoundEffectVariations.MaterialType matType = (SoundEffectVariations.MaterialType)Enum.
                                                                     Parse(typeof(SoundEffectVariations.MaterialType), split[4]);
                        Vector3 worldPos = Camera.main.transform.position + relPos; // Get the world pos from the relative one

                        ServiceLocator.GetService <SoundPlayer>().PlaySoundEffect(soundRef, volMulti, worldPos, matType);
                    }
                }
            }
        }
Exemplo n.º 27
0
 void Start()
 {
     power_part_pos_default = GameObject.Find("Rotation point").transform.position;
     unit_blueprint         = GameObject.Find("DesignPlatform/Unit").GetComponent <UnitBlueprint>();
 }