예제 #1
0
	public bool CanPK( Panel_unit  unit ) 	
	{
		if (unit == null)
			return false;

		return MyTool.CanPK ( this.eCampID , unit.eCampID );
//		if (unit.eCampID != this.eCampID) {
//			if( unit.eCampID == _CAMP._ENEMY || eCampID == _CAMP._ENEMY )
//			{
//				return true;
//			}
//		}
//
//		return false;
	}
예제 #2
0
//	public List< Panel_unit  > GetPKUnitPool( bool bCanPK )
//	{
//		List< Panel_unit  > pool = new List< Panel_unit  >();
//
//
//		return pool;
//	}
//
//	public List<iVec2 > GetPKPosPool( bool bCanPK )
//	{
//		List< iVec2  > pool = new List< iVec2  >();
//		List< Panel_unit  > unitpool = GetPKUnitPool (bCanPK);
//
//		
//		return pool;
//	}

	public int Dist( Panel_unit  unit ) 	
	{
		return this.Loc.Dist (unit.Loc);
	}
예제 #3
0
	public static Panel_CMDUnitUI OpenCMDUI( _CMD_TYPE type , Panel_unit cmder )
	{
		cCMD.Instance.eCMDTYPE = type; 
		Panel_CMDUnitUI panel = MyTool.GetPanel<Panel_CMDUnitUI> ( PanelManager.Instance.OpenUI (Panel_CMDUnitUI.Name) );
		if( panel == null )
		{
			return panel;
		}

		// if cmder is change
		if (cmder != null) {
			panel.SetCmder (cmder);
		}
		cCMD.Instance.eCMDSTATUS = _CMD_STATUS._WAIT_CMDID;

		panel.CreateCMDList (type);
		//if (PanelManager.Instance.CheckUIIsOpening (Panel_CMDUnitUI.Name)) {
		//}

		return panel;
	}
예제 #4
0
	// really close Cmd UI . all param be clear
	void EndCMDUI(  )
	{
		Panel_StageUI.Instance.ClearOverCellEffect();
//		cCMD.Instance.eCMDSTATUS = _CMD_STATUS._NONE;
		PanelManager.Instance.CloseUI( Name );

		if (pCmder != null) {
			pCmder.OnSelected ( false );
			//pCmder.SetDead ();
			pCmder = null;
		}
		CMD.Clear ();
	}
예제 #5
0
	// pre
	public void SetCmder( Panel_unit unit )
	{
		//cancel old
		if (pCmder != null) {
			pCmder.OnSelected( false );
		}
		// clear	

		// setup origin param
		pCmder = unit;
		if( pCmder == null ){			
			return ;
		}


		// who will disable
		pCmder.OnSelected (true);

		// CMD param
		CMD.nCmderIdent = pCmder.Ident();
		CMD.nOrgGridX = pCmder.X();
		CMD.nOrgGridY = pCmder.Y();

		// keep cmd type
		CMD.eCMDSTATUS = _CMD_STATUS._WAIT_CMDID;
		CMD.eCMDTARGET = _CMD_TARGET._ALL;
		CMD.eCMDID 	   = _CMD_ID._NONE;	

	}
예제 #6
0
	public void SetTarget( Panel_unit unit )
	{
		CMD.nTarIdent = 0;
		if( unit != null ){
			CMD.nTarIdent = unit.Ident();
		}

		if( CMD.nAOEID > 0 ){
			CMD.eCMDAOETARGET =  _CMD_TARGET._UNIT;

			int x = pCmder.X();
			int y = pCmder.Y();
			if( unit != null ){
				x = unit.X();
				y = unit.Y();
			}
			Panel_StageUI.Instance.ClearOverCellEffect ();
			Panel_StageUI.Instance.CreateAOEOverEffect( x , y , CMD.nAOEID );
			
			return;
			// block cmd
		}

		cCMD.Instance.eCMDTARGET =  _CMD_TARGET._UNIT;

		// trig attack event
		// check Need Make Cmd
		MakeCmd ();
		// close cmd ui
		//Clear ();
		PanelManager.Instance.CloseUI( Name );
	}
예제 #7
0
	public void ShowBattleMsg( Panel_unit unit , string msg )
	{
		Vector3 v = new Vector3 (0, 0, 0);
		if (unit != null) {
			// show in screen center
			//v = unit.transform.position;
			v = unit.transform.parent.localPosition+unit.transform.localPosition;
		}

		GameObject go = ResourcesManager.CreatePrefabGameObj ( Panel_StageUI.Instance.MaskPanelObj , "prefab/BattleMsg" );
		if (go != null) {
			//go.transform.position = v;
			go.transform.localPosition = v;
			UILabel lbl = go.GetComponentInChildren<UILabel>();
			if( lbl != null )
			{
				lbl.text = msg;
			}
		}

	}
예제 #8
0
	public void  RunSuicide(  )
	{
		PanelManager.Instance.CloseUI( Name );
		if (pCmder != null) {
			pCmder.OnSelected ( false );
			cUnitData pCmdData  = GameDataManager.Instance.GetUnitDateByIdent( pCmder.Ident() );
			if( pCmdData != null ){
				pCmdData.AddHp( -999999999 );
			}
			//pCmder.SetDead ();
		}
		pCmder = null;
		CMD.Clear ();
		// send clear over
		Panel_StageUI.Instance.ClearOverCellEffect ();
	}
예제 #9
0
//	public List< iVec2>  GetTarPosPKPosPool( Panel_unit unit , bool bCanPK  , int nTarX , int nTarY , int nDist = 0 )
//	{
//		List< iVec2> lst = new List< iVec2> ();
//		foreach (KeyValuePair < int , Panel_unit > pair in IdentToUnit) {
//			if( unit.CanPK( pair.Value ) == bCanPK )
//			{
//				lst.Add( pair.Value.Loc );
//			}
//		}		
//		return lst;
//
//	}

	public List< iVec2 > PathFinding( Panel_unit unit , iVec2 st , iVec2 ed , int nStep = 999)
	{
		// nStep = 999; // debug

		List< iVec2 > path = null;
		//List< iVec2 > unitList =  GetUnitPosList();

		// try the short path
		//this.GetUnitPKPosPool (unit, true);

		Grids.ClearIgnorePool();
		Grids.AddIgnorePool (  GetUnitPKPosPool( unit , true  ) );  // all is block in first find

//		List< iVec2 > nearList = Grids.GetRangePool( ed , 1  ); // the 4 pos can't stand ally
//		foreach( iVec2 pos in nearList ){
//			if( CheckIsEmptyPos( pos ) == false ){
//				Grids.AddIgnorePos( pos );
//			}
//		}

		// avoid the end node have ally
		//List< iVec2 > nearList =  GetUnitPKPosPool( unit , );


		path = Grids.PathFinding( st , ed , nStep  );

//		if (path == null) {
//			Grids.ClearIgnorePool();
//			//Grids.AddIgnorePool ( GetUnitPosList() );  // only enemy is block in second find
//			Grids.AddIgnorePool(  GetUnitPKPosPool( unit , true  ) ); //
//			path = Grids.PathFinding( st , ed , nStep  );
//		}

		if (Config.GOD == true) {
			CreatePathOverEffect (path); // draw path
		}

		return path;
	}
예제 #10
0
	void FixPlanePosition()
	{
		// ensure canvrs in screen
		if( TilePlaneObj != null )
		{
			if (TarceMoveingUnit != null ) {
				if( TarceMoveingUnit.IsMoving()== false )
				{
					TarceMoveingUnit = null;
				}else{
					// force to unit
					Vector3 v = TarceMoveingUnit.transform.localPosition;
					v.x *= -1;
					v.y *= -1;

					//get time from speed 200pix /sec
					Vector3 d = TilePlaneObj.transform.localPosition - v;
					float time = d.magnitude  /1000 ;
					TweenPosition tw = TweenPosition.Begin<TweenPosition>(TilePlaneObj , time );
					if( tw ){
						tw.SetStartToCurrentValue();
						tw.to = v;
					}

					//TilePlaneObj.transform.localPosition  = v ;

				}
			}

			//float fMouseX = Input.mousePosition.x;
			//float fMouseY = Input.mousePosition.y;
			
			Vector3 vOffset = TilePlaneObj.transform.localPosition;
			// X 
			if( vOffset.x < fMinOffX ){
				vOffset.x = fMinOffX;
			}
			else if( vOffset.x > fMaxOffX ){
				vOffset.x = fMaxOffX;
			}
			// Y
			if( vOffset.y < fMinOffY ){
				vOffset.y = fMinOffY;
			}
			else if( vOffset.y > fMaxOffY ){
				vOffset.y = fMaxOffY;
			}
			TilePlaneObj.transform.localPosition = vOffset;
		}

	}
예제 #11
0
	public List< iVec2>  GetUnitPKPosPool( Panel_unit unit , bool bCanPK  )
	{

		List< iVec2> lst = new List< iVec2> ();
		foreach (KeyValuePair < int , Panel_unit > pair in IdentToUnit) {
			if( unit.CanPK( pair.Value ) == bCanPK )
			{
				lst.Add( pair.Value.Loc );
			}
		}		
		return lst;
	}
예제 #12
0
	public void TraceUnit( Panel_unit unit )
	{
		if (unit == null)
			return;

		TarceMoveingUnit = unit;
	}
예제 #13
0
	// get nearest pk unit
	public Dictionary< Panel_unit , int > GetUnitDistPool( Panel_unit unit , bool bCanPK )
	{
		Dictionary< Panel_unit , int > pool = new Dictionary< Panel_unit , int > (); // unit , dist
		foreach( KeyValuePair<int ,Panel_unit > pair in IdentToUnit )
		{
			if( unit.CanPK( pair.Value ) == bCanPK )
			{
				int nDist = pair.Value.Loc.Dist( unit.Loc );
				pool.Add( pair.Value , nDist );
			}
		}
		return pool;
	}
예제 #14
0
	public void CreateAttackOverEffect( Panel_unit unit , int nRange=1)
	{
		foreach( KeyValuePair< string , GameObject> pair in OverCellAtkPool )
		{
			if( pair.Value != null )
			{
				NGUITools.Destroy( pair.Value );
				//pair.Value = null;
			}
		}
		OverCellAtkPool.Clear ();
		if (unit == null)
			return;

		if (nRange < 1)
			nRange = 1;

		List<iVec2> AtkList =  Grids.GetRangePool ( unit.Loc, nRange );
		AtkList.RemoveAt (0); // remove self pos

		foreach( iVec2 v in AtkList )
		{
			//GameObject over = ResourcesManager.CreatePrefabGameObj(TilePlaneObj, "Prefab/AttackOverEffect");
			GameObject over = AtkEftObj.Spawn( TilePlaneObj.transform );
			if( over != null )
			{
				over.name = string.Format("ATK Over({0},{1},{2})", v.X , v.Y , 0 );
				SynGridToLocalPos( over , v.X , v.Y) ;
				OverCellAtkPool.Add( v.GetKey() , over );
				over.SetActive( true );
			}
		}

	}
예제 #15
0
	public void CreateMoveOverEffect( Panel_unit unit )
	{
		MoveEftObj.RecycleAll();

		if( OverCellPool != null ){
			OverCellPool.Clear ();
		}
		if (unit == null)
			return;

		//return; // 
		// find move
		cUnitData pdata = GameDataManager.Instance.GetUnitDateByIdent ( unit.Ident() ); 
		// don't zoc 
//		List<iVec2> posList = GetUnitPosList ( );

	//	List<iVec2> moveList =  Grids.GetRangePool (unit.Loc, pdata.GetMov()  , 1);
		Grids.ClearIgnorePool();
		Grids.AddIgnorePool( GetUnitPKPosPool(unit , true  ) );

		List<iVec2> moveList =  Grids.MoveAbleCell (unit.Loc, pdata.GetMov() );

		// try ZOC!!!
	//	List<iVec2> final = Panel_StageUI.Instance.Grids.FilterZocPool (unit.Loc, ref moveList, ref posList);
	//	moveList = final;

		long  tick =  System.DateTime.Now.Ticks; 

		// start create over eff
		foreach( iVec2 v in moveList )
		{
			if ( cMyGrids.IsWalkAbleTile( Grids.GetValue( v ) ) == false  )
			{
				continue;
			}
			// check if this vec can reach


//			List<iVec2> path = PathFinding( unit , unit.Loc , v , pdata.GetMov() );
//			if( path.Count <= 0 )
//				continue;

			// create move over cell
			//GameObject over = ResourcesManager.CreatePrefabGameObj(TilePlaneObj, "Prefab/MoveOverEffect");
			GameObject over = MoveEftObj.Spawn(  TilePlaneObj.transform );
		
			if( over != null )
			{
				over.name = string.Format("Move Over({0},{1},{2})", v.X , v.Y , 0 );
				SynGridToLocalPos( over , v.X , v.Y) ;
				//UIEventListener.Get(over).onClick += OnOverClick;
				
				OverCellPool.Add( v.GetKey() , over );
				over.SetActive( true );
			//	over.transform.SetParent ( TilePlaneObj.transform );
			}
		}

		long  during =  System.DateTime.Now.Ticks - tick ; 

		Debug.Log( "create moveeffect cell with ticket:" + during );
	}