// switch to next Camp. return true if round change public bool NextCamp() { // weakup current camp first for remove unit mask // StageWeakUpCampEvent cmd = new StageWeakUpCampEvent (); // cmd.nCamp = nActiveCamp; // GameEventManager.DispatchEvent ( cmd ); // bool bRoundChange = false; if( nActiveCamp == _CAMP._PLAYER ) { nActiveCamp = _CAMP._ENEMY; // nRoundStatus = _ROUND_STATUS._START; bRoundChange = false; } else if( nActiveCamp == _CAMP._ENEMY ) { nActiveCamp = _CAMP._PLAYER; // nRound++; // nRoundStatus = _ROUND_STATUS._START; bRoundChange = true; } //weak up current for correct re def StageWeakUpCampEvent cmd = new StageWeakUpCampEvent (); cmd.nCamp = nActiveCamp; GameEventManager.DispatchEvent ( cmd ); // open . round change panel ui PanelManager.Instance.OpenUI( Panel_Round.Name ); return bRoundChange; }
public void AddCampMember( _CAMP nCampID , int nMemIdent ) { if( CampPool.ContainsKey( nCampID ) ){ cCamp unit = CampPool[ nCampID ]; if( unit != null ){ if( unit.memLst.Contains( nMemIdent ) == false ) { unit.memLst.Add( nMemIdent ); } } } else{ cCamp unit = new cCamp(); unit.CampID = nCampID; unit.memLst.Add( nMemIdent ); CampPool.Add( nCampID , unit ); } // find unit to set camp cUnitData data = GetUnitDateByIdent ( nMemIdent ); if (data != null) { data.eCampID = nCampID; } }
public void DelCampMember( _CAMP nCampID , int nMemIdent ) { if( CampPool.ContainsKey( nCampID ) ){ cCamp unit = CampPool[ nCampID ]; if( unit != null ) { unit.memLst.Remove( nMemIdent ); } } }
public void SetCamp( _CAMP camp ) { GameDataManager.Instance.DelCampMember( eCampID , Ident() ); // global game data eCampID = camp; UISprite sp = BGObj.GetComponent<UISprite>(); if (sp == null) return; switch (camp) { case _CAMP._PLAYER: sp.color = new Color( 0.0f , 0.0f , 1.0f ); break; case _CAMP._ENEMY: sp.color = new Color( 1.0f , 0.0f , 0.0f ); break; default: sp.color = new Color( 1.0f , 1.0f , 0.0f ); break; } sp.alpha= 0.5f; GameDataManager.Instance.AddCampMember( camp , Ident() ); // global game data }
public Dictionary< _CAMP , cCamp > CampPool; // add Camp public cCamp GetCamp( _CAMP nCampID ) { if( CampPool.ContainsKey( nCampID ) ) { return CampPool[ nCampID ]; } return null; }
// Operation Token ID // public bool CanPK( _CAMP camp1 , _CAMP camp2 ) { return MyTool.CanPK(camp1 , camp2 ); // if (camp1 != camp2 ) { // if( camp1 == _CAMP._ENEMY || camp2 == _CAMP._ENEMY ) // { // return true; // } // } // // return false; }
void DelChar( _CAMP nCampID , int nChar ) { cCamp camp = GameDataManager.Instance.GetCamp( nCampID ); if( camp == null ) return ; List< int > remove = new List< int >(); foreach( int id in camp.memLst ) { if( IdentToUnit.ContainsKey( id ) == true ) { Panel_unit unit = IdentToUnit[ id ]; if( unit != null ) { if( nChar != unit.CharID ) { continue; } //unit.pUnitData; //NGUITools.Destroy( unit.gameObject ); unit.Recycle(); } IdentToUnit.Remove( id ); remove.Add( id ); } else{ // fail obj?? remove.Add( id ); } } foreach( int id in remove ) { camp.memLst.Remove( id ); } }
// Widget func GameObject AddUnit( _CAMP nCampID , int nCharID , int x , int y , int nLeaderIdent = 0 ) { // CHARS charData = GameDataManager.Instance.GetConstCharData (nCharID); //ConstDataManager.Instance.GetRow<CHARS>( nCharID ); // if( charData == null) // return null; // get data from Const data if (TilePlaneObj == null) { Debug.Log( "Stage Addunit to null TilePlane" ); return null; } //GameObject obj = ResourcesManager.CreatePrefabGameObj( TilePlaneObj , "Prefab/Panel_Unit" ); GameObject obj = UnitPanelObj.Spawn( TilePlaneObj.transform ); if( obj == null )return null; obj.name = string.Format ("unit-{0}",nCharID ); // charge face text // UITexture tex = obj.GetComponentInChildren<UITexture>(); // // if( tex ) // { // if(tex != null){ // // DynamicAssetBundleLoader.LoadTexture(tex,DynamicAssetBundleLoader.SSAssetType.Card, "CARD_" + card.PicName); // // string url = "Art/char/" + charData.s_FILENAME +"_S"; // Texture t= Resources.Load <Texture>( url ) ; // tex.mainTexture = t; // // tex.MakePixelPerfect(); don't make pixel it // } // } // regedit to gamedata manager Panel_unit unit = obj.GetComponent<Panel_unit>(); //UNIT_DATA unit = GameDataManager.Instance.CreateChar( nCharID ); if( unit != null ) { // fix to a valid pos iVec2 pos = FindEmptyPos( new iVec2(x , y)); int posx = x; int posy = y; if( pos !=null ){ posx = pos.X; posy = pos.Y; } // setup param unit.CreateChar( nCharID , posx , posy ); unit.SetCamp( nCampID ); unit.SetLevel( StageData.n_MOB_LV ); IdentToUnit.Add( unit.Ident() , unit ) ;// stage gameobj // set game data unit.pUnitData.n_LeaderIdent = nLeaderIdent; // unit.pUnitData.n_X = x; // unit.pUnitData.n_Y = y; } // position // set in create //obj.transform.localPosition = MyTool.SnyGridtoLocalPos( x , y , ref Grids ) ; if (nCampID == _CAMP._PLAYER) { UIEventListener.Get (obj).onClick += OnCharClick; } else if (nCampID == _CAMP._ENEMY) { UIEventListener.Get (obj).onClick += OnMobClick; } // if obj out of screen. move to it auto MoveToGameObj ( obj , false ); // all ready NGUITools.SetActive( obj , true ); return obj; }
bool RunCampAI( _CAMP nCamp ) { // our faction don't need AI process if( nCamp == _CAMP._PLAYER ) return true; // player is playing // change faction if all unit moved or dead. List<Panel_unit> lst = GetUnitListByCamp (nCamp); foreach (Panel_unit unit in lst ) { if( unit.CanDoCmd() ) { unit.RunAI(); return true; } } return false; }
// Faction AI public List<Panel_unit> GetUnitListByCamp( _CAMP nCamp ) { List<Panel_unit> lst = new List<Panel_unit> (); cCamp camp = GameDataManager.Instance.GetCamp( nCamp ); if (camp != null) { foreach( int ident in camp.memLst ) { Panel_unit unit = GetUnitByIdent( ident ); if( unit != null ) { lst.Add( unit ); } } } return lst; }