Ejemplo n.º 1
0
        public override void Awake()
        {
            base.Awake();
            graphics    = GetComponentsInChildren <Graphic>();
            canvasGroup = GetComponent <CanvasGroup>();
            if (canvasGroup == null && RectTrans != null)
            {
                canvasGroup = GO.AddComponent <CanvasGroup>();
            }
            LayoutGroup = GetComponent <LayoutGroup>();

            //初始化变化组件
            EffectShows.AddRange(PosAnimator);
            EffectShows.AddRange(ScaleAnimator);
            foreach (var item in EffectShows)
            {
                item.Init(this);
            }

            sourceAnchorMax          = RectTrans.anchorMax;
            sourceAnchorMin          = RectTrans.anchorMin;
            sourceLocalScale         = RectTrans.localScale;
            sourceSizeData           = RectTrans.sizeDelta;
            sourceAnchoredPosition   = RectTrans.anchoredPosition;
            sourceAnchoredPosition3D = RectTrans.anchoredPosition3D;
            sourcePivot = RectTrans.pivot;
        }
Ejemplo n.º 2
0
        private void OnProcessAssembly()
        {
#if UNITY_EDITOR
            if (!Application.isPlaying)
            {
                return;
            }
            foreach (var item in Assembly.GetExecutingAssembly().GetTypes())
            {
                if (item.IsClass)
                {
                    if (item.IsSubclassOf(typeof(IMUIBase)))
                    {
                        if (item == typeof(IMUIOptions))
                        {
                            continue;
                        }
                        if (!item.IsAbstract && !item.IsGenericType)
                        {
                            GO.AddComponent(item);
                        }
                    }
                }
            }
#endif
        }
Ejemplo n.º 3
0
        public virtual void Run(params object[] param)
        {
            if (_isRunning)
            {
                CLog.LogError("GameRunner,id=" + _id + " is running,can not run again!");
                return;
            }
            _isRunning = true;
            GameCfg gameCfg = GameConfig.GetGameCfg(this._id);

            if (GO == null)
            {
                GO = new GameObject(gameCfg.name);
                GameObject.DontDestroyOnLoad(GO);
            }
            Transform uiTrans = AppManager.Instance.GameStarter.transform.FindChild(gameCfg.ui + "_Template");

            if (uiTrans != null)
            {
                GameObject ui = GameObject.Instantiate(uiTrans.gameObject);
                CTLTools.AddChildToParent(ui, GO, false);
                ui.transform.Find("UICamera").GetComponent <Camera>().depth = gameCfg.uiDepth;
                ui.SetActive(true);
                ui.name = "UI";
            }
            else
            {
                CLog.LogError("can not find UI template in GameStarter!UI:" + gameCfg.ui);
            }

            STContainer = GO.AddComponent <SingletonContainer>();
            STContainer.ResourceMgr.Init(GameConfig.IsResourceLoadMode, string.Format("Assets/{0}/Res", gameCfg.rootDir));
            STContainer.LuaClient.BindGame(gameCfg.id);
            STContainer.LuaClient.StartGame();
        }
Ejemplo n.º 4
0
    private void killThisNPC()
    {
        //do all the calculations/etc here
        //drop the items here
        //etc etc

        if (this.IsNotAFreaking <Player>())
        {
            CreateTextMessage(Name + " is dead!", Color.red);
            Debug.Log(this.Name + " was killed!");
            //time effects need cleared
            List <Item> itemsToDrop = new List <Item>();
            foreach (InventoryCategory ic in Inventory.Values)
            {
                foreach (Item i in ic.Values)
                {
                    Debug.Log("Adding to drop list: " + i.Name);
                    itemsToDrop.Add(i);
                }
            }
            foreach (Item i in itemsToDrop)
            {
                Debug.Log("Dropping item: " + i.Name);
                this.dropItem(i, GridSpace);
            }
            JustUnregister();
            animator.Play(deathState);
            GO.AddComponent <TimedAction>().init(1.5f, new Action(() => { JustDestroy(); }));
        }
        else
        {
            Debug.Log("Player is dead! Uhh, what do we do now?");
        }
    }
Ejemplo n.º 5
0
    public override GameObject Decorate()
    {
        WearableProduct WP = GO.AddComponent <WerableProductInstance>();

        BindingFlags flags = BindingFlags.GetField | BindingFlags.Instance | BindingFlags.NonPublic;

        typeof(Product).GetField("displayName", flags).SetValue(WP, Name);

        AssetManager.Instance.registerObject(WP);
        switch (BodyLocation)
        {
        case bodylocation.head:
            WP.bodyLocation = WearableProduct.BodyLocation.HEAD;
            break;

        case bodylocation.face:
            WP.bodyLocation = WearableProduct.BodyLocation.FACE;
            break;

        case bodylocation.back:
            WP.bodyLocation = WearableProduct.BodyLocation.BACK;
            break;

        default:
            break;
        }
        return(base.Decorate());
    }
Ejemplo n.º 6
0
 //确保有LayoutElement
 public LayoutElement EnsureLayoutElement()
 {
     if (LayoutElement == null)
     {
         LayoutElement = GO.AddComponent <LayoutElement>();
     }
     return(LayoutElement);
 }
Ejemplo n.º 7
0
    public override GameObject Decorate()
    {
        OngoingEffectProductInstance WP = GO.AddComponent <OngoingEffectProductInstance>();

        BindingFlags flags = BindingFlags.GetField | BindingFlags.Instance | BindingFlags.NonPublic;

        typeof(Product).GetField("displayName", flags).SetValue(WP, Name);

        AssetManager.Instance.registerObject(WP);
        WP.duration = duration;
        return(base.Decorate());
    }
Ejemplo n.º 8
0
    public override GameObject Decorate()
    {
        ConsumableProduct CP = GO.AddComponent <ConsumableProductInstance>();

        BindingFlags flags = BindingFlags.GetField | BindingFlags.Instance | BindingFlags.NonPublic;

        typeof(Product).GetField("displayName", flags).SetValue(CP, Name);

        AssetManager.Instance.registerObject(CP);
        switch (ConsumeAnimation)
        {
        case consumeanimation.generic:
            CP.consumeAnimation = ConsumableProduct.ConsumeAnimation.GENERIC;
            break;

        case consumeanimation.drink_straw:
            CP.consumeAnimation = ConsumableProduct.ConsumeAnimation.DRINK_STRAW;
            break;

        case consumeanimation.lick:
            CP.consumeAnimation = ConsumableProduct.ConsumeAnimation.LICK;
            break;

        case consumeanimation.with_hands:
            CP.consumeAnimation = ConsumableProduct.ConsumeAnimation.WITH_HANDS;
            break;

        default:
            break;
        }
        switch (Temprature)
        {
        case temprature.none:
            CP.temperaturePreference = ConsumableProduct.TemperaturePreference.NONE;
            break;

        case temprature.cold:
            CP.temperaturePreference = ConsumableProduct.TemperaturePreference.COLD;
            break;

        case temprature.hot:
            CP.temperaturePreference = ConsumableProduct.TemperaturePreference.HOT;
            break;

        default:
            break;
        }
        CP.portions = portions;
        return(base.Decorate());
    }
Ejemplo n.º 9
0
    private void InitCamp(SoldierType soldierType)
    {
        GameObject GO;
        string     GOName    = "";
        string     name      = "";
        string     icon      = "";
        Vector3    position  = Vector3.zero;
        float      trainTime = 5;

        switch (soldierType)
        {
        case SoldierType.Rookie:
            GOName    = "SoldierCamp_Rookie";
            name      = "新手兵营";
            icon      = "RookieCamp";
            trainTime = 3;
            break;

        case SoldierType.Sergeant:
            GOName    = "SoldierCamp_Sergeant";
            name      = "中士兵营";
            icon      = "SergeantCamp";
            trainTime = 4;

            break;

        case SoldierType.Captain:
            GOName    = "SoldierCamp_Captain";
            name      = "上尉兵营";
            icon      = "CaptainCamp";
            trainTime = 5;
            break;

        default:
            Debug.LogError("无法根据战士类型:" + soldierType + "初始化兵营。");
            break;
        }

        GO       = GameObject.Find(GOName);
        position = UnityTool.FindChild(GO, "TrainPoint").transform.position;
        SoldierCamp soldierCamp = new SoldierCamp(GO, name, icon, soldierType, position, trainTime);

        //CampOnClick campOnclick = GO.AddComponent<CampOnClick>();
        //campOnclick.camp = soldierCamp;
        GO.AddComponent <CampOnClick>().camp = soldierCamp;


        mSoldierCamps.Add(soldierType, soldierCamp);
    }
Ejemplo n.º 10
0
 public override void Awake()
 {
     base.Awake();
     graphics    = GetComponentsInChildren <Graphic>();
     canvasGroup = GetComponent <CanvasGroup>();
     if (canvasGroup == null && RectTrans != null)
     {
         canvasGroup = GO.AddComponent <CanvasGroup>();
     }
     sourceAnchorMax          = RectTrans.anchorMax;
     sourceAnchorMin          = RectTrans.anchorMin;
     sourceLocalScale         = RectTrans.localScale;
     sourceSizeData           = RectTrans.sizeDelta;
     sourceAnchoredPosition   = RectTrans.anchoredPosition;
     sourceAnchoredPosition3D = RectTrans.anchoredPosition3D;
 }
Ejemplo n.º 11
0
    public void Setup(string name, string id, string unit, int layer)
    {
        Name  = name;
        ID    = id;
        Unit  = unit;
        GO    = Utilities.GetGameObjectByName(Name, new string[] { ">>" });
        Layer = layer;
        GO.transform.localScale = new Vector3(20F, 20F, 20F);

        GO.GetComponent <Renderer>().material.color = Color.cyan;
        GO.AddComponent <DataOnClick>();
        GO.GetComponent <DataOnClick>().sensor = this;

        GO.AddComponent <BoxCollider>();
        GO.GetComponent <BoxCollider>().bounds.SetMinMax(GO.GetComponent <Renderer>().bounds.min, GO.GetComponent <Renderer>().bounds.max);
    }
Ejemplo n.º 12
0
    private void OnGUI()
    {
        GUILayout.Space(10);

        GUILayout.Label("Adds chosen material to:");

        GUILayout.Space(15);

        GUILayout.Label("Selected objects");
        material1 = EditorGUILayout.ObjectField(material1, typeof(Material), true);

        GUILayout.Space(10);

        GUILayout.BeginHorizontal();

        EditorGUI.BeginDisabledGroup(simpleDisabled);
        if (GUILayout.Button("Assign to selected", GUILayout.MaxWidth(150)))
        {
            foreach (GameObject GO in Selection.gameObjects)
            {
                Renderer rend = GO.GetComponent <Renderer>();
                if (rend == null)
                {
                    GO.AddComponent(typeof(Material));
                }
                else
                {
                    rend.material = material1 as Material;
                }
            }
        }

        EditorGUI.EndDisabledGroup();

        GUILayout.EndHorizontal();

        Repaint();
    }
Ejemplo n.º 13
0
    private void InitCamp(EnemyType enemyType)
    {
        GameObject GO;
        string     GOName    = "";
        string     name      = "";
        string     icon      = "";
        Vector3    position  = Vector3.zero;
        float      trainTime = 5;

        switch (enemyType)
        {
        case EnemyType.Elf:
            GOName    = "CaptiveCamp_Elf";
            name      = "小精灵俘兵营";
            icon      = "CaptiveCamp";
            trainTime = 3;
            break;


        default:
            Debug.LogError("无法根据敌人类型:" + enemyType + "初始化兵营。");
            break;
        }

        GO       = GameObject.Find(GOName);
        position = UnityTool.FindChild(GO, "TrainPoint").transform.position;
        //SoldierCamp soldierCamp = new SoldierCamp(GO, name, icon, soldierType, position, trainTime);
        CaptiveCamp camp = new CaptiveCamp(GO, name, icon, enemyType, position, trainTime);

        //CampOnClick campOnclick = GO.AddComponent<CampOnClick>();
        //campOnclick.camp = soldierCamp;
        GO.AddComponent <CampOnClick>().camp = camp;


        //mSoldierCamps.Add(soldierType, soldierCamp);
        mCaptiveCamps.Add(enemyType, camp);
    }
Ejemplo n.º 14
0
 override public void open()
 {
     Debug.Log("Main Open");
     GO = (GameObject)GameObject.Instantiate(menu);
     GO.AddComponent <BoxCollider2D>();
 }