// find the neighbhord and check if i need to fight with void UpdateGameLogic(int nCurrentSec) { if( m_AnimalStatus == ANIMAL_STATUS.ANIMAL_STATUS_INIT) { CalculateGameLogic(); m_AnimalStatus = ANIMAL_STATUS.ANIMAL_STATUS_MOVING; m_nCurrentFrame+=1; UI_StatusText.text = "Moving-"+(nCurrentSec)%5; } if( m_AnimalStatus == ANIMAL_STATUS.ANIMAL_STATUS_MOVING) { //if(m_nCurrentFrame >=1000) if( (nCurrentSec)%5 <=0) { // Moving UI_StatusText.text = "Moving-"+ (nCurrentSec)%5; transform.position = Vector3.Lerp(transform.position, Position_Destination, Time.deltaTime*3.5f ); } else { // Finish the Moving transform.position = Position_Destination; m_AnimalStatus = ANIMAL_STATUS.ANIMAL_STATUS_BEHAVIOUR; UI_StatusText.text = "Behaviour-"+ (nCurrentSec)%5; } m_nCurrentFrame+=1; } if( m_AnimalStatus == ANIMAL_STATUS.ANIMAL_STATUS_BEHAVIOUR) { if( (nCurrentSec)%5 <=3) { if( m_AnimalPiece_Behaviour == ANIMAL_BEHAVIOUR.ANIMAL_BEHAVIOUR_MOVE_CASUAL) { UI_StatusText.text = "Behaviour-Move "+ (nCurrentSec)%5; } else if(m_AnimalPiece_Behaviour == ANIMAL_BEHAVIOUR.ANIMAL_BEHAVIOUR_FIGHT) { UI_StatusText.text = "Behaviour-Fight!"+ (nCurrentSec)%5; } } else { m_AnimalStatus = ANIMAL_STATUS.ANIMAL_STATUS_FINISH; UI_StatusText.text = "Finish-"+(nCurrentSec)%5; } m_nCurrentFrame+=1; } if( m_AnimalStatus == ANIMAL_STATUS.ANIMAL_STATUS_FINISH) { m_nCurrentFrame+=1; if( (nCurrentSec)%5 ==4) { UI_StatusText.text = "Finish-"+ (nCurrentSec)%5; if(m_bDistroy == true) { // DistroySelf - show the animation Tile TileStand = BoardClass._game.AllTiles.Single(o => o.X == Piece.Location.X && o.Y == Piece.Location.Y); // get the tile BoardClass.KillAnimalPiece( TileStand); } } else { m_AnimalStatus = ANIMAL_STATUS.ANIMAL_STATUS_INIT; m_nCurrentFrame=0; UI_StatusText.text = "Init"+(nCurrentSec)%5; } } }
// Use this for initialization void Start() { Piece.m_StrongValue=2; CoreGame = GameObject.Find("coreGame"); BoardClass = CoreGame.GetComponent("BoardBehavior") as BoardBehavior; /// Init the TextUI GameObject go = new GameObject("Text_"+ this.name); UI_StatusText = (GUIText)go.AddComponent( typeof(GUIText) ); UI_StatusText.transform.parent = transform; Font BroadwayFont = (Font)Resources.Load("Fonts/Arial"); UI_StatusText.font = BroadwayFont; UI_StatusText.text = "Init"; UI_StatusText.fontSize=16; UI_StatusText.material.color = Color.green; UI_StatusText.transform.position=new Vector3(0,0,0); TextCoords = new Vector3(0,0,0); /// Status control init m_AnimalPiece_Behaviour =m_AnimalPiece_Behaviour_Prev = ANIMAL_BEHAVIOUR.ANIMAL_BEHAVIOUR_IDLE; m_AnimalStatus = ANIMAL_STATUS.ANIMAL_STATUS_INIT; m_nCurrentFrame = 0 ; m_bDistroy = false; UI_StatusText.enabled = ( CoreGame.GetComponent("MainGameWorld") as MainGameWorld).bDebugShowMsg_Creature; }