Ejemplo n.º 1
0
        /*
         * Equipment PartName:
         *   head ---> face  helmet
         *   body ---> chest
         *   gloves ---> gloves
         *   shoes ---> boots
         *   trousers ---> NULL
         */
        void Awake()
        {
            attribute = GetComponent <NpcAttribute>();
            //myAnimationEvent = GetComponent<MyAnimationEvent> ();

            rightHand = Util.FindChildRecursive(transform, "Armature|tag_righthand");
            if (rightHand == null)
            {
                rightHand = Util.FindChildRecursive(transform, "Point001");
            }

            back = Util.FindChildRecursive(transform, "Point002");



            /*
             * first set body shadow then set equipment shadow
             */

            regEvt = new List <MyEvent.EventType>()
            {
                MyEvent.EventType.CharEquipChanged,
                MyEvent.EventType.TryEquip,
            };

            regLocalEvt = new List <MyEvent.EventType>()
            {
                MyEvent.EventType.ShowWeaponTrail,
                MyEvent.EventType.HideWeaponTrail,
            };
            RegEvent();
        }
Ejemplo n.º 2
0
        ///<summary>
        /// 副本内怪物构建流程
        /// 单人副本通过Scene配置来产生怪物
        /// 多人副本通过服务器推送消息产生怪物
        /// </summary>
        //TODO: 多人副本怪物产生机制
        public void CreateMonster(UnitData unitData, SpawnTrigger spawn)
        {
            if (WorldManager.worldManager.station == WorldManager.WorldStation.Enter)
            {
                Log.Sys("UnityDataIs " + unitData.ID);
                if (unitData.Config == null)
                {
                    Debug.LogError("NotFoundMonster " + unitData.ID);
                    return;
                }

                Log.Sys("Create Monster Unit " + unitData.name);
                var Resource = Resources.Load <GameObject> (unitData.ModelName);
                //本地怪兽不需要Player信息
                GameObject   g   = Instantiate(Resource) as GameObject;
                NpcAttribute npc = NGUITools.AddMissingComponent <NpcAttribute> (g);
                npc.spawnTrigger = spawn.gameObject;

                var type = Type.GetType("ChuMeng." + unitData.AITemplate);
                var t    = typeof(NGUITools);
                var m    = t.GetMethod("AddMissingComponent");
                Log.AI("Monster Create Certain AI  " + unitData.AITemplate + " " + type);
                var geMethod = m.MakeGenericMethod(type);
                //var petAI =
                geMethod.Invoke(null, new object[] { g });// as AIBase;


                g.transform.parent = transform;
                g.tag              = GameTag.Enemy;
                g.layer            = (int)GameLayer.Npc;
                spawn.FirstMonster = g;

                var netView = g.GetComponent <KBEngine.KBNetworkView> ();
                netView.SetID(new KBEngine.KBViewID(myPlayer.ID, myPlayer));
                netView.IsPlayer = false;

                npc.SetObjUnitData(unitData);
                AddObject(netView.GetServerID(), netView);


                float   angle = UnityEngine.Random.Range(0, 360);
                Vector3 v     = Vector3.forward;
                v = Quaternion.Euler(new Vector3(0, angle, 0)) * v;
                float rg = UnityEngine.Random.Range(0, spawn.Radius);

                npc.transform.position = spawn.transform.position + v * rg;
                if (unitData.IsElite)
                {
                    npc.transform.localScale = new Vector3(2, 2, 2);
                }

                BattleManager.battleManager.AddEnemy(npc.gameObject);
                npc.SetDeadDelegate = BattleManager.battleManager.EnemyDead;
                //npc.Level = spawn.Level;
            }
            else
            {
                cacheMonster.Add(new MonsterInit(unitData, spawn));
            }
        }
Ejemplo n.º 3
0
 void Awake()
 {
     attribute = GetComponent <NpcAttribute> ();
     //controller = GetComponent<CharacterController> ();
     myAnimationEvent = GetComponent <MyAnimationEvent> ();
     targetPlayer     = null;
 }
Ejemplo n.º 4
0
        IEnumerator KillNpc(MyAnimationEvent.Message msg)
        {
            GetComponent <PlayerAIController> ().enabled = false;

            NpcAttribute attribute = GetComponent <NpcAttribute> ();

            attribute._characterState = CharacterState.Story;


            DialogRender.KillNpcMessage m = (DialogRender.KillNpcMessage)msg;
            var targetName = m.dialog.dialog;
            var target     = GameObject.Find(targetName);

            Debug.Log("start kill Npc");
            yield return(StartCoroutine(commonAI.MoveToPos(target.transform.position)));

            //Rotation And Move To Target Position

            yield return(StartCoroutine(commonAI.KillNpc(target)));

            attribute._characterState = CharacterState.Idle;
            animation.CrossFade("idle");

            GetComponent <PlayerAIController> ().enabled = false;
        }
Ejemplo n.º 5
0
 protected NpcAttribute GetAttr()
 {
     if (attr == null)
     {
         attr = aiCharacter.GetAttr();
     }
     return(attr);
 }
Ejemplo n.º 6
0
        void Start()
        {
            attribute    = GetComponent <NpcAttribute>();
            mvController = GetComponent <MoveController>();
            //mvController.vcontroller = new VirtualController();

            StartCoroutine(CommandHandle());
        }
Ejemplo n.º 7
0
 // Use this for initialization
 IEnumerator Start()
 {
     while (KBEngine.KBEngineApp.app == null)
     {
         yield return(null);
     }
     attribute = GetComponent <NpcAttribute> ();
     if (photonView.IsMe)
     {
         StartCoroutine(InitProperty());
     }
 }
Ejemplo n.º 8
0
        public static void Drop(NpcAttribute mon)
        {
            var treasure = mon.GetDropTreasure();

            foreach (var d in treasure)
            {
                Log.Sys("DropTreasure " + d.Count);
                var itemData = Util.GetItemData(0, (int)d[0]);
                int num      = 1;
                if (d.Count >= 3)
                {
                    num = (int)d[2];
                }

                ItemDataRef.MakeDropItem(itemData, mon.transform.position + new Vector3(0, 0.4f, 0), num);
            }
        }
Ejemplo n.º 9
0
        public void CreateNpc(UnitData unitData, GameObject spawn)
        {
            if (WorldManager.worldManager.station == WorldManager.WorldStation.Enter)
            {
                var        Resource = Resources.Load <GameObject> (unitData.ModelName);
                GameObject g        = Instantiate(Resource) as GameObject;
                if (g.GetComponent <CharacterController>() == null)
                {
                    var c = g.AddComponent <CharacterController>();
                    c.center = new Vector3(0, 0.7f, 0);
                    c.height = 1.6f;
                }

                NpcAttribute npc = NGUITools.AddMissingComponent <NpcAttribute> (g);

                var type = Type.GetType("ChuMeng." + unitData.AITemplate);
                var t    = typeof(NGUITools);
                var m    = t.GetMethod("AddMissingComponent");
                Log.AI("Monster Create Certain AI  " + unitData.AITemplate + " " + type);
                var geMethod = m.MakeGenericMethod(type);
                geMethod.Invoke(null, new object[] { g });// as AIBase;

                g.transform.parent = transform;
                g.tag   = GameTag.Npc; //Player Or Npc
                g.layer = (int)GameLayer.IgnoreCollision;

                //Register Unique Id To Npc
                var netView = g.GetComponent <KBEngine.KBNetworkView> ();
                netView.SetID(new KBEngine.KBViewID(myPlayer.ID, myPlayer));
                netView.IsPlayer = false;

                npc.SetObjUnitData(unitData);
                AddObject(netView.GetServerID(), netView);

                npc.transform.position = spawn.transform.position;
                var rotY = spawn.transform.localRotation.eulerAngles.y;
                npc.transform.localRotation = Quaternion.Euler(new Vector3(0, rotY, 0));

                NpcManager.Instance.RegNpc(unitData.name, g);
            }
            else
            {
                cacheNpc.Add(new MonsterInit(unitData, spawn));
            }
        }
Ejemplo n.º 10
0
        /// <summary>
        /// 初始化Buff
        /// </summary>
        /// <param name="af">Af.</param>
        /// <param name="o">O.</param>
        public virtual void Init(Affix af, GameObject o)
        {
            affix = af;
            obj   = o;
            attri = obj.GetComponent <NpcAttribute>();
            if (affix.UnitTheme != null)
            {
                var par = GameObject.Instantiate(affix.UnitTheme) as GameObject;
                //par.transform.parent = obj.transform;
                var sync = par.AddComponent <SyncPosWithTarget>();
                sync.target = obj;

                par.transform.localPosition = affix.ThemePos;
                par.transform.localRotation = Quaternion.identity;
                par.transform.localScale    = Vector3.one;

                unitTheme = par;
            }
        }
Ejemplo n.º 11
0
        public void CreateChest(UnitData unitData, SpawnChest spawn)
        {
            Log.Sys("Create Chest Unit " + unitData.name);
            var          Resource = Resources.Load <GameObject> (unitData.ModelName);
            GameObject   g        = Instantiate(Resource) as GameObject;
            NpcAttribute npc      = NGUITools.AddMissingComponent <NpcAttribute> (g);

            npc.spawnTrigger = spawn.gameObject;

            var type = Type.GetType("ChuMeng." + unitData.AITemplate);
            var t    = typeof(NGUITools);
            var m    = t.GetMethod("AddMissingComponent");

            Log.AI("Monster Create Certain AI  " + unitData.AITemplate + " " + type);
            var geMethod = m.MakeGenericMethod(type);

            geMethod.Invoke(null, new object[] { g });// as AIBase;

            g.transform.parent = transform;
            g.tag   = GameTag.Enemy;
            g.layer = (int)GameLayer.Npc;

            var netView = g.GetComponent <KBEngine.KBNetworkView> ();

            netView.SetID(new KBEngine.KBViewID(myPlayer.ID, myPlayer));
            netView.IsPlayer = false;

            npc.SetObjUnitData(unitData);
            AddObject(netView.GetServerID(), netView);

            //不算怪物允许不去打
            npc.transform.position = spawn.transform.position;

            BattleManager.battleManager.AddEnemy(npc.gameObject);
            npc.SetDeadDelegate = BattleManager.battleManager.EnemyDead;
        }
Ejemplo n.º 12
0
 void Start()
 {
     attribute = GetComponent <NpcAttribute>();
 }
Ejemplo n.º 13
0
        public void CreatePet(int monsterId, GameObject owner, Affix affix, Vector3 pos)
        {
            Log.Sys("Create Pet " + monsterId + " " + owner + " " + pos);
            if (owner == null)
            {
                Debug.LogError("Own NotExist Pet Not Born");
                return;
            }
            var unitData = Util.GetUnitData(false, monsterId, 1);

            var Resource = Resources.Load <GameObject> (unitData.ModelName);

            GameObject   g    = Instantiate(Resource) as GameObject;
            NpcAttribute npc  = NGUITools.AddMissingComponent <NpcAttribute> (g);
            var          type = Type.GetType("ChuMeng." + unitData.AITemplate);
            var          t    = typeof(NGUITools);
            var          m    = t.GetMethod("AddMissingComponent");

            Log.AI("Create Certain AI  " + unitData.AITemplate + " " + type);
            var geMethod = m.MakeGenericMethod(type);

            //var petAI =
            geMethod.Invoke(null, new object[] { g });// as AIBase;
            //var petAI =
            //NGUITools.AddMissingComponent<type> (g);

            g.transform.parent = transform;
            g.tag   = owner.tag;
            g.layer = (int)GameLayer.Npc;


            npc.SetOwnerId(owner.GetComponent <KBEngine.KBNetworkView> ().GetLocalId());
            npc.spawnTrigger = owner.GetComponent <NpcAttribute>().spawnTrigger;

            //不可移动Buff
            //持续时间Buff
            //无敌不可被攻击Buff
            //火焰陷阱的特点 特点组合
            g.GetComponent <BuffComponent> ().AddBuff(affix);

            var netView = NGUITools.AddMissingComponent <KBEngine.KBNetworkView> (g);

            netView.SetID(new KBEngine.KBViewID(myPlayer.ID, myPlayer));
            netView.IsPlayer = false;
            //owner.GetComponent<NpcAttribute>().AddSummon(netView.gameObject);

            npc.SetObjUnitData(unitData);
            AddObject(netView.GetServerID(), netView);

            npc.transform.position = pos;

            if (unitData.IsElite)
            {
                npc.transform.localScale = new Vector3(2, 2, 2);
            }

            if (npc.tag == GameTag.Enemy)
            {
                BattleManager.battleManager.AddEnemy(npc.gameObject);
                npc.SetDeadDelegate = BattleManager.battleManager.EnemyDead;
            }
        }
Ejemplo n.º 14
0
 void Start()
 {
     attribute   = GetComponent <NpcAttribute>();
     CacheDamage = new List <DamageData>();
 }
Ejemplo n.º 15
0
 void Start()
 {
     attribute = GetComponent <NpcAttribute>();
     //StartCoroutine(CheckFalling());
 }