Example #1
0
    public virtual void Initialize()
    {
        if (null == _mModelName)
        {
            Debug.LogWarning("Building::Initialize is not complete.");
            return;
        }

        Object ob = Resources.Load(_mModelName);

        if (null == ob)
        {
            Debug.LogWarning("The resource " + _mModelName + " is not exist?");
            return;
        }

        _mGameObject = GameObject.Instantiate(ob, Vector3.zero, Quaternion.identity) as GameObject;

        if (_mGameObject == null)
        {
            Debug.LogWarning("The resource " + _mModelName + " is Empty prefab!");
            return;
        }

        _mGameObject.name = _mData.Name;
        GameObject.DontDestroyOnLoad(_mGameObject);

        TagMaskDefine.SetTagRecuisively(_mGameObject, TagMaskDefine.GFAN_NPC);

        AddPropertyComp();
        Create3DName();
    }
    void InitActor()
    {
        PlayerData actorData = Globals.Instance.MGameDataManager.MActorData;

        GirlData wsData = actorData.GetActorFakeWarshipData();

        if (null != wsData)
        {
            actor.UpdateSlot(wsData);
        }
        else
        {
            actor.UpdateAvatarIcon("");
        }
        actor.IsNeedDynamicAdjustColl = true;         // up and down circle

        TagMaskDefine.SetTagRecuisively(actor.gameObject, TagMaskDefine.GFAN_ACTOR);

        // Add move controller
        actor.MoveCtl = actor.gameObject.GetComponent <ObjMoveControl>() as ObjMoveControl;;
        if (null == actor.MoveCtl)
        {
            actor.MoveCtl = actor.gameObject.AddComponent <ObjMoveControl>() as ObjMoveControl;
        }
        actor.MoveCtl.MoveSpeed = moveSpeed;

        //add rigid body
        Rigidbody rigidbody = actor.gameObject.AddComponent <Rigidbody>() as Rigidbody;

        if (rigidbody)
        {
            rigidbody.useGravity  = false;
            rigidbody.isKinematic = true;
        }

        BoxCollider coll = actor.gameObject.GetComponent <BoxCollider>() as BoxCollider;

        if (null == coll)
        {
            coll = actor.gameObject.AddComponent <BoxCollider>() as BoxCollider;
        }
        if (coll)
        {
            coll.isTrigger = true;
            coll.center    = new Vector3(0, 0, 0);
            coll.size      = actor.eventBtn.GetComponent <Collider>().bounds.size;
        }

        actorStartPoint = actor.transform.position;
    }
Example #3
0
    public override void Initialize()
    {
        // Now use the _mData.ModelNam field to search GameObject in current scene
        _mGameObject = GameObject.Find(_mData.NPCIcon);
        //_mGameObject.transform.localScale = Vector3.one;

        if (null == _mGameObject)
        {
            Debug.LogError("Not found the building " + _mData.ModelName);
            return;
        }

        TagMaskDefine.SetTagRecuisively(_mGameObject, TagMaskDefine.GFAN_NPC);

        SyncPropComponet();
        //SyncBuildingSet();
    }
    void InitOneMonster(Transform tf, CopyMonsterData.MonsterData data)
    {
        tf.gameObject.SetActiveRecursively(true);

        UIButton btn = (UIButton)tf.GetComponent(typeof(UIButton));
        //btn.SetInputDelegate(OnScreenBtnInputDel);

        MonsterSet monster = tf.gameObject.GetComponent <MonsterSet>() as MonsterSet;

        if (null == monster)
        {
            monster = tf.gameObject.AddComponent <MonsterSet>() as MonsterSet;
        }

        TagMaskDefine.SetTagRecuisively(tf.gameObject, TagMaskDefine.GFAN_MONSTER);

        monster.UpdateData(data);
        monsterObjs.Add(monster.gameObject);
    }
Example #5
0
    public void Initialize(WarshipL.CreateCallback callback)
    {
        base.Initialize(delegate(WarshipL ws)
        {
            base._mMoveSpeed = 40.0f;

            // Set the monster fleet orientation
            Quaternion rotation = Quaternion.AngleAxis(180, Vector3.up);
            base.U3DGameObject.transform.rotation = rotation;

            Show3DName(true);

            _mVisibleTrigger = null;
            InitTriggers();
            InitAIScripts();

            TagMaskDefine.SetTagRecuisively(U3DGameObject, TagMaskDefine.GFAN_MONSTER);
            if (null != callback)
            {
                callback(this);
            }
        }
                        );
    }