Beispiel #1
0
        public static AINpc AddNpc(string Name, Vector2 Position, CombatTeam Team, float Scale, float[] InitAttr)
        {
            // temp code, r1 or r2 role
            var AtkRange = InitAttr[(int)NpcAttrIndex.AtkRange];

            var Obj = AssetManager.CreatePrefabSync(new AssetUri(AtkRange > 100 ? "prefabs/npc/r1/r1.prefab" : "prefabs/npc/r2/r2.prefab"));

            MapManager.AddToNpcLayer(Obj.transform);
            Obj.transform.localPosition = Position;

            var Entity = new AINpc(Name, Obj.transform, Team, InitAttr);

            NpcList_[(int)Team].Add(Entity);
            Entity.Position = Position;
            Entity.Scale    = new Vector2(Scale, Scale);
            Entity.GetBar().SetScale(0.5f);

            if (AtkRange > 100)
            {
                Entity.Skill.AddNpcSkill(1002).Radius = CombatHelper.GetNpcAtkRange(Entity);
            }
            else
            {
                Entity.Skill.AddNpcSkill(1001).Radius = CombatHelper.GetNpcAtkRange(Entity);
            }

            EventManager.Send(new NpcAddEvent(Entity));
            return(Entity);
        }
Beispiel #2
0
        public static CoreNpc AddCoreNpc(string Name, Vector2 Position, float[] InitAttr)
        {
            if (CoreNpc_ != null)
            {
                return(CoreNpc_);
            }

            var Obj = AssetManager.CreatePrefabSync(new AssetUri("prefabs/npc/core/core.prefab"));

            MapManager.AddToNpcLayer(Obj.transform);
            Obj.transform.localPosition = Position;

            CoreNpc_ = new CoreNpc(Name, Obj.transform, InitAttr);
            NpcList_[(int)CombatTeam.A].Add(CoreNpc_);
            CoreNpc_.Position = Position;
            CoreNpc_.IsStatic = true;
            CoreNpc_.GetBar().SetScale(2.0f);

            EventManager.Send(new NpcAddEvent(CoreNpc_));
            return(CoreNpc_);
        }