public static ActorBehaviour CreateActorBehaviour(string fileName, GameObject model, ActorType eType, ActorGroup actorGroup, uint actorID)
        {
            GameObject obj = new GameObject(fileName);

            if (model != null)
            {
                model.transform.parent        = obj.transform;
                model.transform.localPosition = Vector3.zero;
                model.transform.localScale    = Vector3.one;
            }
            ActorBehaviour refActorBehaviour = null;

            switch (eType)
            {
            case ActorType.NONE:
                break;

            case ActorType.HERO:
                break;

            case ActorType.MONSTER:
                break;

            case ActorType.SCENE_OBJ:
                break;

            case ActorType.SCENE_SKILLDESTROY_OBJ:
                break;

            case ActorType.VIRSUAL_OBJ:
                refActorBehaviour = Utils.AddMissComponent <ActorBehaviour_Virsual>(obj);
                break;

            case ActorType.NONATTACK_OBJ:
                break;

            case ActorType.TEST_OBJ:
                refActorBehaviour = Utils.AddMissComponent <ActorBehaviour_Test>(obj);
                break;

            case ActorType.COUNT:
                break;

            default:
                break;
            }
            if (refActorBehaviour == null)
            {
                return(null);
            }

            refActorBehaviour.Init(model, eType, actorGroup, actorID);

            return(refActorBehaviour);
        }
Exemple #2
0
        public bool RemoveActor(uint uid)
        {
            ActorBehaviour actor = null;

            if (!_actorsDic.TryGetValue(uid, out actor))
            {
                return(false);
            }

            if (actor != null)
            {
                _actorsDic.Remove(uid);

                actor.RemoveSelf();

                GameObject.Destroy(actor.gameObject);
            }

            return(true);
        }
Exemple #3
0
 public void Init(ActorBehaviour actor)
 {
     _actor = actor;
 }
Exemple #4
0
        /// <summary>
        /// 创建ActorBehaviour
        /// </summary>
        /// <param name="actorID">角色ID,读表用,不唯一</param>
        /// <param name="actorType"></param>
        /// <param name="prefab_path"> 测试用,正式用actorID创建</param>
        /// <returns></returns>
        ActorBehaviour CreateActorGameObject(uint actorID, ActorType actorType, ActorGroup actorGroup, string prefab_path = "", Property property = new Property())
        {
            GameObject model = null;

            switch (actorType)
            {
            case ActorType.NONE:
                break;

            case ActorType.HERO:
                model = CreateHeroGameObject(actorID);
                break;

            case ActorType.MONSTER:
                model = CreateMonsterGameObject(actorID);
                break;

            case ActorType.SCENE_OBJ:
                break;

            case ActorType.TEST_OBJ:
                model = CreateGameObjectByPrefabPath(prefab_path, FileNameType.RESOURCE_NAME);
                break;

            case ActorType.SCENE_SKILLDESTROY_OBJ:
                break;

            case ActorType.VIRSUAL_OBJ:
                break;

            case ActorType.NONATTACK_OBJ:
                break;

            case ActorType.COUNT:
                break;

            default:
                break;
            }

            if (model == null && actorType != ActorType.VIRSUAL_OBJ)
            {
                Debug.Log(string.Format("create actor Error , actorID :{0} , ActorType :{1}", actorID, actorType));
                return(null);
            }

            string modelName = model == null ? "VIRSUAL" : model.name;
            string fileName  = string.Format("[{0}].{1}.{2}", actorType, actorID, modelName);

            ActorBehaviour refActor = ActorBehaviour.CreateActorBehaviour(fileName, model, actorType, actorGroup, actorID);

            if (refActor != null)
            {
                if (!_actorsDic.ContainsKey(refActor.UID))
                {
                    _actorsDic.Add(refActor.UID, refActor);
                }
                else
                {
                    Debug.LogError("contain object");
                    refActor.RemoveSelf();
                    GameObject.Destroy(refActor.gameObject);
                }
            }

            return(refActor);
        }
Exemple #5
0
 public void OnEventActorDie(ActorBehaviour actor)
 {
     RemoveSelf();
 }