void UpdateGameLogic(int nCurrentSec) { // GUITimer // Result //just calculate all the logic if( m_HumanStatus == HUMAN_STATUS.HUMAN_STATUS_INIT ) { // check the activity CalculateGameLogic(); // do the init m_HumanStatus = HUMAN_STATUS.HUMAN_STATUS_MOVING; m_nCurrentFrame+=1; UI_StatusText.text = "Moving-"+(nCurrentSec)%5; } if( m_HumanStatus== HUMAN_STATUS.HUMAN_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_HumanStatus = HUMAN_STATUS.HUMAN_STATUS_BEHAVIOUR; UI_StatusText.text = "Behaviour-"+ (nCurrentSec)%5; } m_nCurrentFrame+=1; } if( m_HumanStatus== HUMAN_STATUS.HUMAN_STATUS_BEHAVIOUR ) { //if(m_nCurrentFrame >=3000) if( (nCurrentSec)%5 <=3) { // Building Behavior if (m_HumanPiece_Behaviour == HUMAN_BEHAVIOUR.HUMAN_BEHAVIOUR_BUILD) { // Show the Building Animation. // Add the Building on this tile. //BoardClass.Building_Culture ; UI_StatusText.text = "Behaviour-Building-"+ (nCurrentSec)%5; } else if( m_HumanPiece_Behaviour == HUMAN_BEHAVIOUR.HUMAN_BEHAVIOUR_BUILD_USE) { UI_StatusText.text = "Behaviour-BuildingUse-"+ (nCurrentSec)%5; } else if( m_HumanPiece_Behaviour == HUMAN_BEHAVIOUR.HUMAN_BEHAVIOUR_GETRESOURCE) { UI_StatusText.text = "Behaviour-Get Resource-"+ (nCurrentSec)%5; } else if( m_HumanPiece_Behaviour == HUMAN_BEHAVIOUR.HUMAN_BEHAVIOUR_FIGHT ) { UI_StatusText.text = "Behaviour-Fight-"+ (nCurrentSec)%5; } } else { GameObject newBuilding; if (m_HumanPiece_Behaviour == HUMAN_BEHAVIOUR.HUMAN_BEHAVIOUR_BUILD) { /// create new building Quaternion rotation = Quaternion.identity; rotation.eulerAngles = new Vector3(180,0,0); BuildingBehavior.BUILDING_TYPE nBuildType = (BuildingBehavior.BUILDING_TYPE)UnityEngine.Random.Range( 0 , (int)BuildingBehavior.BUILDING_TYPE.BUILDING_TYPE_COUNT); if(nBuildType == BuildingBehavior.BUILDING_TYPE.BUILDING_TYPE_CULTURE) newBuilding = Instantiate( BoardClass.Building_Culture , Position_Destination, rotation) as GameObject; else if(nBuildType == BuildingBehavior.BUILDING_TYPE.BUILDING_TYPE_HEALTH) newBuilding = Instantiate( BoardClass.Building_Health , Position_Destination, rotation) as GameObject; else if(nBuildType == BuildingBehavior.BUILDING_TYPE.BUILDING_TYPE_SCIENCE) newBuilding = Instantiate( BoardClass.Building_Science , Position_Destination, rotation) as GameObject; else newBuilding = Instantiate( BoardClass.Building_Culture , Position_Destination, rotation) as GameObject; // add location info to BuildingBehavior pb = (BuildingBehavior)newBuilding.GetComponent("BuildingBehavior"); pb.m_BuildingType = nBuildType; //m_BuildingType newBuilding.transform.parent = GameObject.Find("Environments_Building").transform; pb.Piece = new GamePiece( new Point( Piece.X , Piece.Y) ); BoardClass._gamePieces_Buildings.Add(newBuilding); } else if (m_HumanPiece_Behaviour == HUMAN_BEHAVIOUR.HUMAN_BEHAVIOUR_BUILD_USE) { // Get the building on the tile // Position_Destination // "AddPoint_Culture" MainGameWorld MainGameWorldClass = CoreGame.GetComponent("MainGameWorld") as MainGameWorld; MainGameWorldClass.BroadcastMessage("AddPoint_Culture"); } else if (m_HumanPiece_Behaviour == HUMAN_BEHAVIOUR.HUMAN_BEHAVIOUR_GETRESOURCE) { // Get the building on the tile // Position_Destination // "AddPoint_Mine" //123 MainGameWorld MainGameWorldClass = CoreGame.GetComponent("MainGameWorld") as MainGameWorld; MainGameWorldClass.BroadcastMessage("AddPoint_Mine"); } else if( m_HumanPiece_Behaviour == HUMAN_BEHAVIOUR.HUMAN_BEHAVIOUR_FIGHT ) { //UI_StatusText.text = "Behaviour-Fight-"+ (nCurrentSec)%5; //m_bDistroy = true; } m_HumanStatus = HUMAN_STATUS.HUMAN_STATUS_FINISH; UI_StatusText.text = "Finish-"+(nCurrentSec)%5; } m_nCurrentFrame+=1; } if( m_HumanStatus== HUMAN_STATUS.HUMAN_STATUS_FINISH ) { m_nCurrentFrame+=1; //if(m_nCurrentFrame >=5000) 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.KillHumanPiece( TileStand); } } else { m_HumanStatus = HUMAN_STATUS.HUMAN_STATUS_INIT; m_nCurrentFrame=0; UI_StatusText.text = "Init"+(nCurrentSec)%5; } } }
// Use this for initialization void Start() { m_HumanType = HUMAN_TYPE.HUMAN_TYPE_NORMAL; // 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; // GText.material.color = Color.Green; UI_StatusText.transform.position=new Vector3(0,0,0); TextCoords = new Vector3(0,0,0); /// Status control init m_HumanPiece_Behaviour =m_HumanPiece_Behaviour_Prev = HUMAN_BEHAVIOUR.HUMAN_BEHAVIOUR_IDLE; m_HumanStatus = HUMAN_STATUS.HUMAN_STATUS_INIT; m_nCurrentFrame = 0 ; m_bDistroy = false; UI_StatusText.enabled = ( CoreGame.GetComponent("MainGameWorld") as MainGameWorld).bDebugShowMsg_Creature; }