public void Start() { //champ_type = Champion.champion_name.Garen;//TODO test only //load the champion //first of all, clear the champion object //foreach (var comp in Utility.get_champion_object (gameObject).GetComponents<Component>()){ // if (!(comp is Transform)) // Destroy(comp); //} //then assign the right champion //switch (champ_type) { //case Champion.champion_name.Garen: // champ = Utility.get_champion_object (gameObject).AddComponent <Garen>() as Champion; // champ.init (); // break; //default: // break; //} //TODO test only champ = Utility.get_champ_script(gameObject); UI_Champion champ_UI = Utility.get_UI_obj(gameObject).GetComponent <UI_Champion> (); champ_UI.init(); champ.ui = champ_UI; gold = 0; }
//Virtuals public override void init() { ui = Utility.get_UI(transform.parent.gameObject); ui_champ = Utility.get_UI(transform.parent.gameObject) as UI_Champion; fac = Types.Faction.OTHER; autoAtkTimer = new Utility.Timer(1f); Q_timer = new Utility.Timer(0f); W_timer = new Utility.Timer(0f); E_timer = new Utility.Timer(0f); R_timer = new Utility.Timer(0f); Passive_timer = new Utility.Timer(0f); death_timer = new Utility.Timer(0f); //not using this for now ai_takeover_timer = new Utility.Timer(GameSceneConsts.ai_takeover_time); status = new List <Status> (); self_col = GetComponent <Collider> (); init_AtkTarget(); init_resources(); //navagent = transform.parent.FindChild("NavUnit").gameObject.GetComponent<NavMeshAgent>(); //navagent.transform.SetParent (null); //navagent.gameObject.AddComponent (Network); //navagent.updateRotation = false; //navagent.updatePosition = false; rotation_override = false; }
//called everywhere, so only necessary part will be initialized public void Start() //(Champion.champion_name _name, Types.Faction _fac, int _idx){ //then assign the right champion { if (isLocalPlayer) { return; } switch (champ_type) { case Champion.champion_name.Garen: champ = Utility.get_champion_object(gameObject).AddComponent <Garen>() as Champion; champ.init(); break; case Champion.champion_name.Ashe: champ = Utility.get_champion_object(gameObject).AddComponent <Garen>() as Champion; champ.init(); break; default: champ = Utility.get_champion_object(gameObject).AddComponent <Garen>() as Champion; champ.init(); break; } unit = champ; //assemble the champion champ.fac = fac; champ.host = this; if (isLocalPlayer) { champ.isPlayer = true; } AI champ_ai = Utility.get_AI_script(gameObject); champ_ai.init(champ, champ.self_col, AI.PotentialTarget.HOSTILE, AI.Decision.HOLD); champ.AI_unit = champ_ai; //TODO test only UI_Champion champ_UI = Utility.get_UI_obj(gameObject).GetComponent <UI_Champion> (); champ_UI.init(); champ.ui = champ_UI; }
//when local player has authority public override void OnStartLocalPlayer() { print("OnStartLocalPlayer"); base.OnStartLocalPlayer(); //if (!isLocalPlayer) // return; GameSceneManager.instance.register_local_player(this); navunit = Instantiate(GameSceneConsts.NavUnit_player, transform.position, transform.rotation) as GameObject; Cmdinstantiate_navunit(navunit); if (navunit == null) { print("navNULL"); } //then assign the right champion switch (champ_type) { case Champion.champion_name.Garen: champ = Utility.get_champion_object(gameObject).AddComponent <Garen>() as Champion; champ.init(); break; default: champ = Utility.get_champion_object(gameObject).AddComponent <Garen>() as Champion; champ.init(); break; } unit = champ; champ.navagent = navunit.GetComponent <UnityEngine.AI.NavMeshAgent> (); champ.navagent.updateRotation = false; //champ.navagent.updatePosition = false; champ.update_movement_speed(); GetComponent <CatchUPUnit> ().host = champ; //assemble the champion champ.fac = fac; champ.host = this; if (isLocalPlayer) { champ.isPlayer = true; } AI champ_ai = Utility.get_AI_script(gameObject); champ_ai.init(champ, champ.self_col, AI.PotentialTarget.HOSTILE, AI.Decision.HOLD); champ.AI_unit = champ_ai; //TODO test only UI_Champion champ_UI = Utility.get_UI_obj(gameObject).GetComponent <UI_Champion> (); champ_UI.init(); champ.ui = champ_UI; gold = 100000; //init its own controller GameSceneManager.instance.ctrlScript.init(gameObject, champ_type); //init its own LOCAL UI GameSceneManager.instance.LocalUI.init(this); champ.host = this; champ.netUnit = this as NetworkUnit; base.init(champ, champ.runtime_u_stats.max_hp, champ.runtime_u_stats.max_mana); }