private void IniSoldierCamp(Type soldierType, string name, string iconName, float trainTime)
    {
        var      go       = GameObject.Find("Camps").transform.Find(soldierType.ToString()).gameObject;
        var      spawnPos = go.transform.Find("Camp/TrainPoint").position;
        BaseCamp camp     = new SoldierCamp(name, iconName, soldierType, spawnPos, trainTime);

        go.AddComponent <CampOnClick>().Camp = camp; //添加点击事件监测脚本

        soldierCamps.Add(soldierType, camp);
    }
Beispiel #2
0
    // 取得场景中的兵营
    private SoldierCamp SoldierCampFactory(ENUM_Soldier emSoldier)
    {
        string GameObjectName = "SoldierCamp_";
        float  CoolDown       = 0;
        string CampName       = "";
        string IconSprite     = "";

        switch (emSoldier)
        {
        case ENUM_Soldier.Rookie:
            GameObjectName += "Rookie";
            CoolDown        = 3;
            CampName        = "菜鳥兵营";
            IconSprite      = "RookieCamp";
            break;

        case ENUM_Soldier.Sergeant:
            GameObjectName += "Sergeant";
            CoolDown        = 4;
            CampName        = "中士兵营";
            IconSprite      = "SergeantCamp";
            break;

        case ENUM_Soldier.Captain:
            GameObjectName += "Captain";
            CoolDown        = 5;
            CampName        = "上尉兵营";
            IconSprite      = "CaptainCamp";
            break;

        default:
            Debug.Log("沒有指定[" + emSoldier + "]要取得的场景物件名称");
            break;
        }

        // 取得物件
        GameObject theGameObject = UnityTool.FindGameObject(GameObjectName);

        // 取得集合点
        Vector3 TrainPoint = GetTrainPoint(GameObjectName);

        // 产生兵营
        SoldierCamp NewCamp = new SoldierCamp(theGameObject, emSoldier, CampName, IconSprite, CoolDown, TrainPoint);

        NewCamp.SetPBaseDefenseGame(m_PBDGame);

        // 设定兵营使用的Script
        AddCampScript(theGameObject, NewCamp);

        return(NewCamp);
    }
    void UnitTest_Camp()
    {
        theSoldierCamp = new SoldierCamp(null, ENUM_Soldier.Rookie, "測試", "", 2, Vector3.zero);
        theCaptiveCamp = new CaptiveCamp(null, ENUM_Enemy.Elf, "測試", "", 3, Vector3.zero);

        //  執行訓練
        theSoldierCamp.Train();
        theSoldierCamp.Train();
        theSoldierCamp.Train();

        theCaptiveCamp.Train();
        theCaptiveCamp.Train();
        theCaptiveCamp.Train();
    }
Beispiel #4
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);
    }
	// 取得場景中的兵營
	private SoldierCamp SoldierCampFactory( ENUM_Soldier emSoldier )
	{
		string GameObjectName = "SoldierCamp_";
		float CoolDown = 0;
		string CampName = "";
		string IconSprite = "";
		switch( emSoldier )
		{
		case ENUM_Soldier.Rookie:
			GameObjectName += "Rookie";
			CoolDown = 3;
			CampName = "菜鳥兵營";
			IconSprite = "RookieCamp";
			break;
		case ENUM_Soldier.Sergeant:
			GameObjectName += "Sergeant";
			CoolDown = 4;
			CampName = "中士兵營";
			IconSprite = "SergeantCamp";
			break;
		case ENUM_Soldier.Captain:
			GameObjectName += "Captain";
			CoolDown = 5;
			CampName = "上尉兵營";
			IconSprite = "CaptainCamp";
			break;
		default:
			Debug.Log("沒有指定["+emSoldier+"]要取得的場景物件名稱");
			break;				
		}

		// 取得物件
		GameObject theGameObject = UnityTool.FindGameObject( GameObjectName );

		// 取得集合點
		Vector3 TrainPoint = GetTrainPoint( GameObjectName );

		// 產生兵營
		SoldierCamp NewCamp = new SoldierCamp(theGameObject, emSoldier, CampName, IconSprite, CoolDown, TrainPoint); 
		NewCamp.SetPBaseDefenseGame( m_PBDGame );

		// 設定兵營使用的Script
		AddCampScript( theGameObject, NewCamp);

		return NewCamp;
	}
Beispiel #6
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);
    }
Beispiel #7
0
    private void InitCamp(SoldierType soldierType)
    {
        GameObject gameObject     = null;
        string     gameObjectName = null;
        string     name           = null;
        string     icon           = null;
        Vector3    position       = Vector3.zero;
        float      trainTime      = 0f;

        //aSong:这个switch可以用文档加载的方式解决
        switch (soldierType)
        {
        case SoldierType.Rookie:
            gameObjectName = "SoldierCamp_Rookie";
            name           = "新手兵营";
            icon           = "RookieCamp";
            trainTime      = 3f;
            break;

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

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

        default:
            Debug.LogError("无法匹配到指定战士类型 [" + soldierType + "]初始化兵营");
            break;
        }
        gameObject = GameObject.Find(gameObjectName);
        position   = gameObject.FindChildTraversing("TrainPoint").transform.position;
        SoldierCamp camp = new SoldierCamp(gameObject, name, icon, soldierType, position, trainTime);

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

        mDic_SoldierCamps.Add(soldierType, camp);
    }
Beispiel #8
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);
    }
    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);
    }
Beispiel #10
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);
    }
	void UnitTest_Camp()
	{
		theSoldierCamp = new SoldierCamp(null, ENUM_Soldier.Rookie, "測試", "", 2, Vector3.zero); 
		theCaptiveCamp = new CaptiveCamp(null, ENUM_Enemy.Elf, "測試", "", 3, Vector3.zero); 

		//  執行訓練
		theSoldierCamp.Train();
		theSoldierCamp.Train();
		theSoldierCamp.Train();

		theCaptiveCamp.Train();
		theCaptiveCamp.Train();
		theCaptiveCamp.Train();
	}