We want the transition to be as quick as possible. The game is not oriented to operate on mobile platforms.
We may try to have less stuff in awake/start.
As for the code of the UnitAI, it’s not a matter of code stealing, the code is highly convoluted since it calls other functions and we set each unit type separately.
We called 2.5D but truth is, our game is 3D Game with billboarded sprites Tile Based (hence the SortingOrderInZAllChildren script).
We mainly do 3 operations:
SetMe(meProvisionalEditor);
SceneControl.SetSideUsingUnit(this,unit);
boolresurrect = unit.bMerc && SceneControl.control.MercIsRespawning(unit);
listAlteredState = newList();
if(!resurrect)
{
me=newUnitRTSUnit();
me.rtsUnit=unit;
}
else
{
GetMercebinaryFromRTSUnit(unit);
}
me.goCharacter=this.gameObject;
me.unitAI=this;
if(unit.bMerc && me.iExpAcumulative>0)
{
me.listSkills=me.listSkills;
}
UnitNavMeshAgentunitNavMeshAgent=GetComponent();
if(unitNavMeshAgent==null)
{
//aitype=AIType.Obstacle;
}
elseif(me.rtsUnit.fForm==RTSUnit.Form.Torre)
{
//aitype=AIType.Tower;
//gameObject.layer=10;//Noselepuedeponerlayer 10
}
else
{
unitNavMeshAgent.SetSeekerPenalties(me.rtsUnit);
unitNavMeshAgent.StartHeight(me.rtsUnit.fLevitateHeight);
}
if(iSide>1)
{
bIsInAgro=true;
}
if(me.rtsUnit.fForm==RTSUnit.Form.Torre)
{
InitTower();
}
if(!IsObstacle()&& !IsMuro()&& !IsTower())
{
me.SetUnitSpeed();
}
gameObject.name=me.rtsUnit.sName;
me.InitIngame(gameObject);
//Initialize graphics
if(!IsObstacle()&& !IsMuro())
{
SetUnitWithRTSUnit(me.rtsUnit,me);
}
if(me.rtsUnit.bIntelligentAvoidance)
{
bIntelligentAvoidance=me.rtsUnit.bIntelligentAvoidance;
}
if(unitNavMeshAgent !=null)
{
unitNavMeshAgent.UpdateFacingRightOrLeft();
}
SortingOrderByZAllChildrensorting=GetComponentInChildren();
sorting.Reset();
sorting.UpdateOrderInLayer();
// ChangeColorChilds
if(transform.GetChild(0).GetChild(0).gameObject.GetComponent()==null)
{
transform.GetChild(0).GetChild(0).gameObject.AddComponent();
}
// Alphaslow
if(transform.GetChild(0).gameObject.GetComponent()==null)
{
AlphaSlowalphaslow=transform.GetChild(0).gameObject.AddComponent();
alphaslow.listIgnoreSprite=newList();
alphaslow.listIgnoreSprite.Add(transform.GetChild(0).GetChild(0).gameObject.GetComponent());
if(unitInfo !=null)unitInfo.alphaSlow=alphaslow;
}
//GetComponentInChildren().AdjustColliderPlane();
Billboardbillboard=GetComponentInChildren();
billboard.DoBillboard();
if(CameraRTS.cameraRTS !=null&&CameraRTS.cameraRTS.minimap !=null)imageMinimap=CameraRTS.cameraRTS.minimap.SetMinimapPosition(this,refbRepresentInMinimap);
InitializeUnitInfo();
//Getthe components
unitInfo.unitAI=GetComponent();
unitInfo.unitNavMeshAgent=GetComponent();
unitInfo.unitAttackManager=GetComponent();
unitInfo.unitSpecialSkill=GetComponent();
unitInfo.obstacle=GetComponent();
unitInfo.obstacleClickCollider=GetComponentInChildren();
unitInfo.unitPenalty=GetComponent();
unitInfo.interactiveRadius=GetComponent();
unitInfo.billboard=GetComponentInChildren();
unitInfo.alphaSlow=GetComponentInChildren();
unitInfo.unitAnimations=GetComponentInChildren();
InitializeAIStates();
if(standbyState==null) standbyState=newStandbyState(this);
if(movingState==null) movingState=newMovingState(this);
if(fallingState==null) fallingState=newFallingState(this);
if(movingToAttackState==null) movingToAttackState=newMovingToAttackState(this);
if(movingToDialogue==null) movingToDialogue=newMovingToDialogue(this);
if(movingRestoreState==null) movingRestoreState=newMovingRestoreState(this);
if(movingToSkillState==null) movingToSkillState=newMovingToSkillState(this);
if(attackingState==null) attackingState=newAttackingState(this);
if(doingSpecialSkillState==null) doingSpecialSkillState=newDoingSpecialSkillState(this);
if(deadState==null) deadState=newDeadState(this);