Пример #1
0
    public override void Init()
    {
        base.Init();
        GameObject canvas = GameObject.Find("Canvas");

        mRootUI = UnityTool.FindChild(canvas, "GamePauseUI");

        mCurretStageLevel = UITools.FindChild <Text>(mRootUI, "CurretStageLevel");
        mContinueBtn      = UITools.FindChild <Button>(mRootUI, "ContinueButton");
        mBackMenuBtn      = UITools.FindChild <Button>(mRootUI, "BackMenuButton");

        mContinueBtn.onClick.AddListener(() =>
        {
            mRootUI.SetActive(false);
            Time.timeScale = 1;
        });

        mBackMenuBtn.onClick.AddListener(() =>
        {
            if (mFacade.IsGameOver == false)
            {
                mFacade.IsGameOver = true;
            }
            Time.timeScale = 1;
        });

        Hide();
    }
Пример #2
0
    private void InitCamp(EnemyType enemyType)
    {
        string gameObjectName = null;
        string name           = "";

        string icon      = "";
        float  trainTime = 0f;

        switch (enemyType)
        {
        case EnemyType.Elf:
            gameObjectName = "CaptiveCamp_Elf";
            name           = "伏兵营";
            icon           = "CaptiveCamp";
            trainTime      = 3f;
            break;

        default:
            Debug.LogError("无法根据战士类型" + enemyType + "初始化兵营");
            break;
        }
        GameObject  gameObject  = gameObject = GameObject.Find(gameObjectName);
        Vector3     position    = UnityTool.FindChild(gameObject, "TrainPoint").transform.position;
        CaptiveCamp camp        = new CaptiveCamp(gameObject, name, icon, enemyType, position, trainTime);
        CampOnClick campOnClick = gameObject.AddComponent <CampOnClick>();

        campOnClick.camp = camp;
        mCamptiveCamp.Add(enemyType, camp);
    }
Пример #3
0
    private void Awake()
    {
        _instance = this;
        gameTrans = UnityTool.FindChild(gameObject, "Game").transform;
        lvInfoMgr = LevelInfoMgr.Instance;
        mapMaker  = GetComponent <MapMaker>();

        enemyBuilder   = new EnemyBuilder();
        towerBuilder   = new TowerBuilder();
        bullectBuilder = new BullectBuilder();
        currentLevel   = GameRoot.Instance.pickLevel;
        info           = lvInfoMgr.levelInfoList[currentLevel];
        //初始化地图
        mapMaker.InitAllGrid();
        mapMaker.LoadLevelMap(currentLevel);
        //获得关卡数据和回合数据
        SetLevelData(info);

        level = new Level(info);
        level.HandleRound();
        beginPos = level.roundInfoList[0].pathList[0];
        EventCenter.Broadcast(EventType.SetStartPos, beginPos);
        isPause = true;
        EventCenter.AddListener <int>(EventType.UseItemInGame, UseItem);
    }
Пример #4
0
    private void InitCamp(EnemyType enemyType)
    {

        GameObject gameObject = null;
        string gameObjectName = null;
        string name = "";
        string icon = "";
        Vector3 position = Vector3.zero;
        float trainTime = 0;
        switch (enemyType)
        {
            case EnemyType.Elf:
                gameObjectName = "CaptiveCamp_Elf";
                name = "俘兵营";
                icon = "CaptiveCamp";
                trainTime = 3;
                break;            
            default:
                Debug.LogError("无法根据敌人类型:" + enemyType + "初始化兵营");
                break;
        }
        gameObject = GameObject.Find(gameObjectName);
        GameObject gameObjectPos = UnityTool.FindChild(gameObject, "TrainPoint");
        if (gameObjectPos != null)
        {
            position = gameObjectPos.transform.position;
            gameObjectPos.SetActive(false);
        }

        CaptiveCamp camp = new CaptiveCamp(gameObject, name, icon, enemyType, position, trainTime);
        camp.IsCaptiveCamp = true;
        gameObject.AddComponent<CampOnClick>().Camp = camp;//添加点击组件       

        mCaptiveCamps.Add(enemyType, camp);
    }
Пример #5
0
    //初始化俘兵营
    private void InitCamp(EnemyType enemyType)
    {
        GameObject gameObject     = null;
        string     gameObjectName = null;
        string     name           = null;
        string     iconSprite     = null;
        Vector3    position       = Vector3.zero;
        float      trainTime      = 0;

        switch (enemyType)
        {
        case EnemyType.Elf:
            gameObjectName = "CaptiveCamp_Elf";
            name           = "俘兵营";
            iconSprite     = "CaptiveCamp";
            trainTime      = 3;
            break;

        default:
            Debug.LogError("无法根据俘兵类型" + enemyType + "初始化兵营");
            break;
        }
        gameObject = GameObject.Find(gameObjectName);
        position   = UnityTool.FindChild(gameObject, "TrainPoint").transform.position;
        CaptiveCamp camp = new CaptiveCamp(gameObject, name, iconSprite, enemyType, position, trainTime);
        //添加监听点击脚本
        CampOnClick campOnClick = gameObject.AddComponent <CampOnClick>();

        campOnClick.Camp = camp;
        mCaptiveCamps.Add(enemyType, camp);
    }
    private void InitCamp(EnemyType enemyType)
    {
        GameObject gameObject     = null;
        string     gameObjectName = null;
        string     name           = null;
        string     icon           = null;
        Vector3    position       = Vector3.zero;
        float      trainTime      = 0;

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

        default:
            Debug.Log("CampSystem InitCamp() " + enemyType + "can't solve");
            break;
        }
        gameObjectName = "Camp/" + gameObjectName;
        gameObject     = GameObject.Find(gameObjectName);
        position       = UnityTool.FindChild(gameObject, "TrainPoint").transform.position;
        CaptiveCamp camp = new CaptiveCamp(gameObject, name, icon, enemyType, position, trainTime);

        gameObject.AddComponent <CampMono>().OnInit(camp);
        captiveCamps.Add(enemyType, camp);
    }
Пример #7
0
    void HitFrameTrigger(string str)
    {
        string[] ts = str.Split('_');
        //for(int i = 0; i < ts.Length; i++)
        //{
        //    print(ts[i]);
        //}
        Transform tar  = null;
        string    str2 = ts[1] + "_" + ts[2];

        //print(str2);
        switch (ts[0])
        {
        case "behit":
            tar = hitPos.Find(str2);
            break;

        case "block":
            GameObject go = UnityTool.FindChild(gameObject, str2);
            tar = go.transform;
            break;
        }
        hitEffect.transform.position = tar.position;
        hitEffect.Play();
        print(tar.name);
    }
Пример #8
0
    public override void Init()
    {
        base.Init();
        GameObject canvas = GameObject.Find("Canvas");

        mRootUI = UnityTool.FindChild(canvas, "GameStateUI");

        GameObject heart1 = UnityTool.FindChild(mRootUI, "Heart1");
        GameObject heart2 = UnityTool.FindChild(mRootUI, "Heart2");
        GameObject heart3 = UnityTool.FindChild(mRootUI, "Heart3");

        mHearts = new List <GameObject>();
        mHearts.Add(heart1);
        mHearts.Add(heart2);
        mHearts.Add(heart3);
        mSoldierCount = UITool.FindChild <Text>(mRootUI, "SoldierCount");

        mEnemyCount   = UITool.FindChild <Text>(mRootUI, "EnemyCount");
        mCurrentStage = UITool.FindChild <Text>(mRootUI, "StageCount");
        mPauseBtn     = UITool.FindChild <Button>(mRootUI, "PauseBtn");
        mGameOverUI   = UnityTool.FindChild(mRootUI, "GameOver");
        mBackMenuBtn  = UITool.FindChild <Button>(mRootUI, "BackMenuBtn");
        mMessage      = UITool.FindChild <Text>(mRootUI, "Message");
        mEnergySlider = UITool.FindChild <Slider>(mRootUI, "EnergySlider");
        mEnergyText   = UITool.FindChild <Text>(mRootUI, "EnergyText");

        mMessage.text = "";
        mGameOverUI.SetActive(false);
    }
Пример #9
0
    public override void Init()
    {
        base.Init();
        GameObject canvas = GameObject.Find("Canvas");

        mRootUI = UnityTool.FindChild(canvas, "GameStateInfoUI");

        GameObject heart1 = UnityTool.FindChild(mRootUI, "heart1");
        GameObject heart2 = UnityTool.FindChild(mRootUI, "heart2");
        GameObject heart3 = UnityTool.FindChild(mRootUI, "heart3");

        mHearts = new List <GameObject>();
        mHearts.Add(heart1);
        mHearts.Add(heart2);
        mHearts.Add(heart3);

        mSoldierNum   = UITool.FindChild <Text>(mRootUI, "SoldierNum");
        mEnemyNum     = UITool.FindChild <Text>(mRootUI, "EnemyNum");
        mStageNum     = UITool.FindChild <Text>(mRootUI, "StageNum");
        mBtnPause     = UITool.FindChild <Button>(mRootUI, "BtnPause");
        mEnergySlider = UITool.FindChild <Slider>(mRootUI, "EnergySlider");
        mEnergyNum    = UITool.FindChild <Text>(mRootUI, "EnergyNum");
        mMessage      = UITool.FindChild <Text>(mRootUI, "Message");
        mGameOver     = UnityTool.FindChild(mRootUI, "GameOver");
        mBtnBackMain  = UITool.FindChild <Button>(mGameOver, "BtnBackMain");
        AddListeners();

        mMessage.text  = "";
        mStageNum.text = mCurrentStageNum.ToString();
        mGameOver.SetActive(false);
    }
    public void OnInit(AbsCharacter _charater)
    {
        owner = _charater;
        GameObject parent = UnityTool.FindChild(_charater.CharacterGameObject, "weapon-point");

        UnityTool.AttachGameObject(parent, gameObject);
    }
Пример #11
0
    public override void Init()
    {
        base.Init();
        GameObject canvas = GameObject.Find("Canvas");

        mRootUI = UnityTool.FindChild(canvas, "CampInfoUI");

        mCampIcon    = UITool.FindChild <Image>(mRootUI, "CampIcon");
        mCampName    = UITool.FindChild <Text>(mRootUI, "CampName");
        mCampLevel   = UITool.FindChild <Text>(mRootUI, "CampLv");
        mWeaponLevel = UITool.FindChild <Text>(mRootUI, "WeaponLv");

        mCampUpgradeBtn   = UITool.FindChild <Button>(mRootUI, "CampUpgradeBtn");
        mWeaponUpgradeBtn = UITool.FindChild <Button>(mRootUI, "WeaponUpgradeBtn");
        mTrainBtn         = UITool.FindChild <Button>(mRootUI, "TrainBtn");
        mTrainBtnText     = UITool.FindChild <Text>(mRootUI, "TrainCostText");
        mCancelTrainBtn   = UITool.FindChild <Button>(mRootUI, "CancelTrainBtn");

        mAliveCount = UITool.FindChild <Text>(mRootUI, "AliveCount");
        mTrainCount = UITool.FindChild <Text>(mRootUI, "TrainCount");
        mTrainTime  = UITool.FindChild <Text>(mRootUI, "TrainTime");

        mTrainBtn.onClick.AddListener(OnTrainClick);
        mCancelTrainBtn.onClick.AddListener(OnCancelTrainClick);
        mCampUpgradeBtn.onClick.AddListener(OnCampUpgradeClick);
        mWeaponUpgradeBtn.onClick.AddListener(OnWeaponUpgradeClick);

        Hide();
    }
Пример #12
0
    public override void StateStart()
    {
        GameObject root = GameObject.Find("Login");

        BtnPaly = UnityTool.FindChild(root, "BtnPlay").GetComponent <Button>();
        BtnExit = UnityTool.FindChild(root, "BtnExit").GetComponent <Button>();
        BtnPaly.onClick.AddListener(OnPlayClick);
        BtnExit.onClick.AddListener(OnExitClick);
    }
Пример #13
0
    public static T FindChild <T>(GameObject parent, string childName)
    {
        GameObject uiGO = UnityTool.FindChild(parent, childName);

        if (uiGO == null)
        {
            return(default(T));
        }
        return(uiGO.GetComponent <T>());
    }
Пример #14
0
    public static T FindChild <T>(GameObject parent, string childName)
    {
        GameObject uiGO = UnityTool.FindChild(parent, childName);

        if (uiGO == null)
        {
            Debug.LogError("UITool.FindChild<T>()  : 在游戏物体" + parent.name + "下查找不到" + childName);
            return(default(T));
        }
        return(uiGO.GetComponent <T>());
    }
Пример #15
0
    /// <summary>
    /// 得到某物体组件
    /// </summary>
    /// <typeparam name="T"></typeparam>
    /// <param name="parent"></param>
    /// <param name="childName"></param>
    /// <returns></returns>
    public static T FindChild <T>(GameObject parent, string childName) where T : Component
    {
        GameObject uiGO = UnityTool.FindChild(parent, childName);

        if (uiGO == null)
        {
            Debug.LogError("在游戏物体下" + parent + "查找不到" + childName);
            return(default(T));
        }
        return(uiGO.GetComponent <T>());
    }
Пример #16
0
    public override void Init()
    {
        base.Init();
        GameObject canvas = GameObject.Find("Canvas");

        mRootUI         = UnityTool.FindChild(canvas, "GamePauseUI");
        mCurrentStageLv = UITool.FindChild <Text>(mRootUI, "CurrentStageLv");
        mContinueButton = UITool.FindChild <Button>(mRootUI, "ContinueButton");
        mBackButton     = UITool.FindChild <Button>(mRootUI, "BackButton");
        Hide();
    }
Пример #17
0
    // 初始化兵营
    private void InitCamp()
    {
        string     campIcon_red = "";
        GameObject go           = UnityTool.FindChild(mMapParentGO, "RedCamp");

        mRedCamp = new SoldierCamp(go, "RedCamp", campIcon_red, CampType.Red);

        string campIcon_blue = "";

        go        = UnityTool.FindChild(mMapParentGO, "BlueCamp");
        mBlueCamp = new SoldierCamp(go, "BlueCamp", campIcon_blue, CampType.Blue);
    }
Пример #18
0
    private ICamp mCamp;     //  点击的兵营



    public override void Init()
    {
        base.Init();
        GameObject canvas = GameObject.Find("Canvas");

        mRootUI = UnityTool.FindChild(canvas, "CampInfoUI");

        mCampIcon = UITool.FindChild <Image>(mRootUI, "CampIcon");
        mCampName = UITool.FindChild <Text>(mRootUI, "CampName");


        Hide();
    }
Пример #19
0
    public override void Init()
    {
        base.Init();
        lvInfoMgr      = LevelInfoMgr.Instance;
        pauseBtn       = Find <Button>("Btn_Pause");
        startBtn       = Find <Button>("Btn_Start");
        Txt_TotalRound = Find <Text>("Txt_TotalRound");
        Txt_NowRound   = Find <Text>("Txt_NowRound");
        Txt_Life       = Find <Text>("Txt_Life");
        Txt_Coin       = Find <Text>("Txt_Coin");

        enemyInfoPanel = UnityTool.FindChild(rootUI, "EnemyInfo");
        towerInfoPanel = UnityTool.FindChild(rootUI, "TowerInfo");
        Txt_EnemyName  = UITool.FindChild <Text>(enemyInfoPanel, "Txt_Name");
        Txt_TowerName  = UITool.FindChild <Text>(towerInfoPanel, "Txt_Name");
        Txt_NowLife    = UITool.FindChild <Text>(enemyInfoPanel, "Txt_NowLife");
        Txt_TotalLife  = UITool.FindChild <Text>(enemyInfoPanel, "Txt_TotalLife");
        Txt_Heart      = UITool.FindChild <Text>(enemyInfoPanel, "Txt_Heart");
        Txt_Def        = UITool.FindChild <Text>(enemyInfoPanel, "Txt_Def");
        Txt_Mdef       = UITool.FindChild <Text>(enemyInfoPanel, "Txt_Mdef");
        Txt_Speed      = UITool.FindChild <Text>(enemyInfoPanel, "Txt_Speed");
        Txt_Phy        = UITool.FindChild <Text>(towerInfoPanel, "Txt_Phy");
        Txt_Magic      = UITool.FindChild <Text>(towerInfoPanel, "Txt_Magic");
        Txt_CD         = UITool.FindChild <Text>(towerInfoPanel, "Txt_CD");
        Txt_Range      = UITool.FindChild <Text>(towerInfoPanel, "Txt_Range");

        Btn_Bag     = Find <Button>("Btn_Bag");
        Bag_BG      = Find <Transform>("Bag_BG").gameObject;
        ItemContent = UITool.FindChild <Transform>(Bag_BG, "ItemContent");

        Bag_BG.SetActive(false);
        enemyInfoPanel.SetActive(false);
        towerInfoPanel.SetActive(false);
        EventCenter.AddListener <int>(EventType.Play_CoinUpdate, SetCoinNum);
        EventCenter.AddListener <int>(EventType.Play_LifeUpdate, SetLifeNum);
        EventCenter.AddListener <int>(EventType.Play_NowRoundUpdate, SetNowRound);
        EventCenter.AddListener(EventType.RestartGame, RestartGame);
        EventCenter.AddListener <GridPoint>(EventType.HandleGrid, HandleGrid);
        EventCenter.AddListener <BaseEnemy>(EventType.HandleEnemy, HandleEnemy);
        EventCenter.AddListener <Vector3>(EventType.SetStartPos, SetStartBtnPos);
        EventCenter.AddListener(EventType.LeaveGameScene, RestartGame);
        pauseBtn.onClick.AddListener(OnPauseClick);
        startBtn.onClick.AddListener(OnStartClick);
        startBtn.gameObject.SetActive(false);

        Btn_Bag.onClick.AddListener(OnBtnBGClick);

        itemBtnList = new List <ItemHoldBtn>();
        SetItemHoldBtn();
    }
Пример #20
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);
    }
Пример #21
0
    public override void Init()
    {
        base.Init();
        GameObject canvas = GameObject.Find("Canvas");

        mRootUI  = UnityTool.FindChild(canvas, "GameStateInfoUI");
        mPauseUI = UnityTool.FindChild(canvas, "GamePauseUI");

        GameObject heart1 = UnityTool.FindChild(mRootUI, "Heart1");
        GameObject heart2 = UnityTool.FindChild(mRootUI, "Heart2");
        GameObject heart3 = UnityTool.FindChild(mRootUI, "Heart3");

        mHearts.Add(heart1);
        mHearts.Add(heart2);
        mHearts.Add(heart3);

        mSoldierCount = UITools.FindChild <Text>(mRootUI, "SoldierCount");
        mEnemyCount   = UITools.FindChild <Text>(mRootUI, "EnemyCount");
        mCurretStage  = UITools.FindChild <Text>(mRootUI, "StageCount");
        mPauseBtn     = UITools.FindChild <Button>(mRootUI, "PauseButton");
        mBackMenuBtn  = UITools.FindChild <Button>(mRootUI, "BackMenuButton");
        mGameOverUI   = UnityTool.FindChild(mRootUI, "GameOver");
        mMessage      = UITools.FindChild <Text>(mRootUI, "Message");
        mEnergySlider = UITools.FindChild <Slider>(mRootUI, "EnergySlider");
        mEnergyText   = UITools.FindChild <Text>(mRootUI, "EnergyText");

        mMessage.text = "";
        mGameOverUI.SetActive(false);

        //注册观察者
        mFacade.RegisterObserver(GameEventType.EnemyEscaped, new EnemyEscapedObserverGameStateInfoUI(this));

        //暂停按钮监听事件
        mPauseBtn.onClick.AddListener(() =>
        {
            mPauseUI.SetActive(true);
            Time.timeScale = 0;
        });

        //游戏结束返回菜单按钮监听事件
        mBackMenuBtn.onClick.AddListener(() =>
        {
            if (mFacade.IsGameOver == false)
            {
                mFacade.IsGameOver = true;
            }
            Time.timeScale = 1;
        });
    }
Пример #22
0
    public override void Init()
    {
        base.Init();
        GameObject canvas = GameObject.Find("Canvas");

        mRootUI = UnityTool.FindChild(canvas, "GamePauseUI");

        mCurrentStageLv = UITool.FindChild <Text>(mRootUI, "CurrentStageLv");
        mContinueBtn    = UITool.FindChild <Button>(mRootUI, "ContinueBtn");
        mBackMenueBtn   = UITool.FindChild <Button>(mRootUI, "BackMenueBtn");

        mContinueBtn.onClick.AddListener(OnContinueClick);
        mBackMenueBtn.onClick.AddListener(OnBackMenueClick);
        Hide();
    }
Пример #23
0
    public override void Init()
    {
        base.Init();

        // 获取Canvas  在Canvas获取暂停UI
        GameObject canvas = GameObject.Find("Canvas");

        mRootUI = UnityTool.FindChild(canvas, "GamePauseUI");

        currentStageLv = UITool.FindChild <Text>(mRootUI, "CurrentStageLv");
        continueBtn    = UITool.FindChild <Button>(mRootUI, "ContinueBtn");
        backMenuBtn    = UITool.FindChild <Button>(mRootUI, "BackMenuBtn");

        Hide();
    }
Пример #24
0
    private Button mBtnBackMain;   //返回主页


    public override void Init()
    {
        base.Init();
        GameObject canvas = GameObject.Find("Canvas");

        mRootUI = UnityTool.FindChild(canvas, "GamePauseUI");

        mCurrentStageNum = UITool.FindChild <Text>(mRootUI, "CurrentStageNum");
        mBtnContinue     = UITool.FindChild <Button>(mRootUI, "BtnContinue");
        mBtnBackMain     = UITool.FindChild <Button>(mRootUI, "BtnBackMain");

        AddListeners();

        Hide();
    }
Пример #25
0
    public override void Init()
    {
        base.Init();
        GameObject canvas = GameObject.Find("Canvas");

        mRootUI      = UnityTool.FindChild(canvas, "SoldierInfoUI");
        mSoldierIcon = UITool.FindChild <Image>(mRootUI, "SoldierIcon");
        mSoldierName = UITool.FindChild <Text>(mRootUI, "SoldierName");
        mHPNumber    = UITool.FindChild <Text>(mRootUI, "HPNumber");
        mHPSlider    = UITool.FindChild <Slider>(mRootUI, "HPSlider");
        mLevel       = UITool.FindChild <Text>(mRootUI, "Level");
        mAtk         = UITool.FindChild <Text>(mRootUI, "Atk");
        mAtkRange    = UITool.FindChild <Text>(mRootUI, "AtkRange");
        mMoveSpeed   = UITool.FindChild <Text>(mRootUI, "MoveSpeed");
        Hide();
    }
Пример #26
0
    /// <summary>
    /// 初始化兵营
    /// </summary>
    /// <param name="soldierType"></param>
    private void InitCamp(SoldierType soldierType)
    {
        GameObject gameObject = null;
        string gameObjectName = null;
        string name ="";
        string icon = "";        
        Vector3 position = Vector3.zero;
        float trainTime = 0;
        switch (soldierType)
        {
            case SoldierType.Rookie:
                gameObjectName = "SoldierCamp_Rookie";
                name = "新手兵营";
                icon = "RookieCamp";
                trainTime = 3;
                break;
            case SoldierType.Sergeant:
                gameObjectName = "SoldierCamp_Sergeant";
                name = "中士兵营";
                icon = "SergeantCamp";
                trainTime = 4;
                break;
            case SoldierType.Captain:
                gameObjectName = "SoldierCamp_Captain";
                name = "上尉兵营";
                icon = "CaptainCamp";
                trainTime = 5;
                break;
            default:
                Debug.LogError("无法根据战士类型:"+soldierType+"创建兵营");
                break;
        }
        gameObject = GameObject.Find(gameObjectName);
        GameObject gameObjectPos = UnityTool.FindChild(gameObject, "TrainPoint");
        if(gameObjectPos!=null)
        {
            position = gameObjectPos.transform.position;
            gameObjectPos.SetActive(false);
        }        
        SoldierCamp camp = new SoldierCamp(gameObject, name, icon, soldierType, position,trainTime);

        gameObject.AddComponent<CampOnClick>().Camp=camp;//添加点击组件       

        mSoldierCamps.Add(soldierType, camp);
    }
Пример #27
0
    private void InitCamp(SoldierType soldierType)
    {
        GameObject gameObject     = null;
        string     gameObjectName = null;
        string     name           = null;
        string     iconSprite     = null;
        Vector3    position       = Vector3.zero;
        float      trainTime      = 0;

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

        case SoldierType.Sergeant:
            gameObjectName = "SoldierCamp_Sergeant";
            name           = "中士兵营";
            iconSprite     = "SergeantCamp";
            trainTime      = 4;
            break;

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

        default:
            Debug.LogError("无法根据战士类型" + soldierType + "初始化兵营");
            break;
        }
        gameObject = GameObject.Find(gameObjectName);
        position   = UnityTool.FindChild(gameObject, "TrainPoint").transform.position;
        SoldierCamp camp = new SoldierCamp(gameObject, name, iconSprite, soldierType, position, trainTime);
        //添加监听点击脚本
        CampOnClick campOnClick = gameObject.AddComponent <CampOnClick>();

        campOnClick.Camp = camp;
        mSoldierCamps.Add(soldierType, camp);
    }
Пример #28
0
    public override void Init()
    {
        base.Init();
        GameObject canvas = GameObject.Find("Canvas");

        mRootUI = UnityTool.FindChild(canvas, "SoldierInfoUI");

        mSoldierIcon = UITool.FindChild <Image>(mRootUI, "SoldierIcon");
        mSoldierName = UITool.FindChild <Image>(mRootUI, "SoldierName");
        mHPText      = UITool.FindChild <Text>(mRootUI, "hp");
        mHPSlider    = UITool.FindChild <Slider>(mRootUI, "hpSlider");
        mLv          = UITool.FindChild <Text>(mRootUI, "lv");
        mAtk         = UITool.FindChild <Text>(mRootUI, "atk");
        mAtkRange    = UITool.FindChild <Text>(mRootUI, "range");
        mMoveSpeed   = UITool.FindChild <Text>(mRootUI, "speed");

        Hide();
    }
Пример #29
0
    private void InitCamp(SoldierType type)
    {
        GameObject gameObject     = null;
        string     gameObejctName = "";
        string     name           = "";
        string     icon           = "";
        Vector3    pos            = Vector3.zero;
        float      trainTime      = 0;

        switch (type)
        {
        case SoldierType.Rookie:
            gameObejctName = "SoldierCamp_Rookie";
            name           = "新手";
            icon           = "RookieCamp";
            trainTime      = 3;
            break;

        case SoldierType.Sergeant:
            gameObejctName = "SoldierCamp_Sergeant";
            name           = "中士";
            icon           = "SergeantCamp";
            trainTime      = 4;
            break;

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

        default:
            break;
        }
        gameObject = GameObject.Find(gameObejctName);

        pos = UnityTool.FindChild(gameObject, "TrainPoint").transform.position;
        SoldierCamp camp = new SoldierCamp(gameObject, name, icon, type, pos, trainTime);

        gameObject.AddComponent <CampClick>().Camp = camp;

        mSoldierCamps.Add(type, camp);
    }
    private void InitCamp(SoldierType soldierType)
    {
        GameObject gameObject     = null;
        string     gameObjectName = null;
        string     name           = null;
        string     icon           = null;
        Vector3    position       = Vector3.zero;
        float      trainTime      = 0;

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

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

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

        default:
            Debug.Log("CampSystem InitCamp() " + soldierType + "can't solve");
            break;
        }
        gameObjectName = "Camp/" + gameObjectName;
        gameObject     = GameObject.Find(gameObjectName);
        position       = UnityTool.FindChild(gameObject, "TrainPoint").transform.position;
        SoldierCamp camp = new SoldierCamp(gameObject, name, icon, soldierType, position, trainTime);

        gameObject.AddComponent <CampMono>().OnInit(camp);
        soldierCamps.Add(soldierType, camp);
    }