Esempio n. 1
0
    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;
    }
    //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);
    }