/// <summary>
    /// 缓存血条
    /// </summary>
    /// <param name="b"></param>
    static void CacheBlood(GfxBlood b)
    {
        if (!OptimitzedControlPlane.Instance.EnityCreateOptimize || null == b)
        {
            return;
        }


        ENTITY_TYPE entity_Type = b.bloodType;

        if (!m_CacheBlood.ContainsKey(entity_Type))
        {
            Debug.LogError("缓存" + entity_Type + "类型血条失败,请在InitCache中添加!");
            return;
        }
        int id = b.ID;

        //不存主角
        if (id == EntityFactory.MainHeroID)
        {
            return;
        }
        if (m_BloodMap.ContainsKey(id))
        {
            b.SetEnable(false);
            b.SetBloodColor(false);
            b.ChangeParent(CacheBloodRoot.transform);
            Queue <GfxBlood> m_list = m_CacheBlood[entity_Type];
            m_list.Enqueue(b);
            m_BloodMap.Remove(id);
        }
    }
Example #2
0
    private static void InsertToMap(ResNode obj, ENTITY_TYPE entityType)
    {
        PrefabNode prefabNode = new PrefabNode();

        prefabNode.OrginalObj = obj;

        int cacheCount = 0;

        //如果是怪物,缓存
        if (entityType == ENTITY_TYPE.TYPE_MONSTER)
        {
            cacheCount = monsterInitCacheCount;
        }
        else
        {
            cacheCount = playerInitCacheCount;
        }

        for (int i = 0; i < cacheCount; i++)
        {
            prefabNode.m_PrefabList.Enqueue(prefabNode.Instantiate(entityType));
        }
        prefabNode.m_Type = entityType;
        m_PrefabMap.Add(entityType, prefabNode);
        obj = null;
    }
Example #3
0
        /// <summary>
        /// 获取指定的实体
        /// </summary>
        /// <param name="entity_id">实体ID</param>
        /// <param name="entity_type">实体类型ENTITY_TYPE</param>
        /// <returns></returns>
        /// <remarks>指定类型时搜索速度会更快</remarks>
        public EntityView Get(ENTITY_ID entity_id, ENTITY_TYPE entity_type)
        {
            IDictionary <int, EntityView> collection = null;

            if (entity_type == ENTITY_TYPE.TYPE_PLAYER_ROLE)
            {
                collection = m_playerEntities;
            }
            else if (entity_type == ENTITY_TYPE.TYPE_MONSTER)
            {
                collection = m_monsterEntities;
            }
            else
            {
                collection = m_entities;
            }

            if (collection.Count == 0)
            {
                return(null);
            }

            if (!collection.ContainsKey(entity_id))
            {
                return(null);
            }

            return(collection[entity_id]);
        }
Example #4
0
    /// <summary>
    /// 取得预制体,失败返回null
    /// </summary>
    /// <param name="entityType">实体类型(是怪物,还是人物..)</param>
    /// <returns></returns>
    public static GameObject GetPrefab(ENTITY_TYPE entityType)
    {
        if (!bInit)
        {
            return(null);
        }

        if (m_PrefabMap.ContainsKey(entityType))
        {
            PrefabNode prefabNode = m_PrefabMap[entityType];
            if (prefabNode.m_PrefabList.Count > 0)
            {
                GameObject go = prefabNode.m_PrefabList.Dequeue();
                go.SetActive(true);
                go.transform.SetParent(null);
                go.name = entityType.ToString();
                return(go);
            }
            else
            {
                GameObject go = prefabNode.Instantiate(entityType);
                go.SetActive(true);
                go.transform.SetParent(null);
                go.name = entityType.ToString();
                return(go);
            }
        }
        return(null);
    }
Example #5
0
        private (string, BaseEntity) GetEntity(ENTITY_TYPE type, uint id)
        {
            string     err    = null;
            BaseEntity entity = null;

            if (_entities.ContainsKey(type))
            {
                err = "entity type: " + type.ToString() + " is not exists";
            }

            foreach (var e in _entities[type])
            {
                if (e.Id == id)
                {
                    entity = e;
                }
                break;
            }

            if (entity == null)
            {
                err = "entity type: " + type + " id:" + id + " is not exists";
            }

            return(err, entity);
        }
Example #6
0
        public Entity(Node node, int id, GuestRoom room, ENTITY_TYPE etype = ENTITY_TYPE.GUEST)
        {
            MyRoom      = room;
            MyNode      = node;
            ID          = id;
            EType       = etype;
            Moving      = false; //An entity only moves after it is given a destination.
            Checked_Out = false; //An entity only checks out when when the event is triggered or during evacuation.

            //If the Entity type is a "MAID" it is given the image of a maid, otherwise the default image is that of a guest and the room the guest is assigned to is set to reserved.
            switch (etype)
            {
            case ENTITY_TYPE.MAID:
                MyImage = Image.FromFile(@"..\..\Images\maid.png");
                break;

            default:
                MyImage = Image.FromFile(@"..\..\Images\TempGuest4.png");
                MyRoom.Reserved_room();
                break;
            }

            //New picturebox created for the entity to be drawn on.
            panelPb = new PictureBox
            {
                Size = MyImage.Size,
                BackgroundImageLayout = ImageLayout.None,
                Parent    = node.panelPb,
                BackColor = Color.Transparent
            };
            node.panelPb.Controls.Add(panelPb);
            panelPb.BackgroundImage = MyImage;
            panelPb.BringToFront();
            Redraw();
        }
Example #7
0
    public static void CachePrefab(ENTITY_TYPE entityType, GameObject prefab)
    {
        if (!bInit)
        {
            return;
        }

        //如果还有子节点,删一下,避免带给下一个实体
        if (prefab != null && prefab.transform.childCount > 0)
        {
            for (int i = prefab.transform.childCount - 1; i >= 0; i--)
            {
                UnityEngine.Object.Destroy(prefab.transform.GetChild(i).gameObject);
            }
        }

        if (m_PrefabMap.ContainsKey(entityType))
        {
            prefab.name = entityType.ToString() + "--cache";
            PrefabNode prefabNode = m_PrefabMap[entityType];
            prefab.SetActive(false);
            prefab.transform.SetParent(PrefabCacheRoot.transform);
            // prefab.transform.localPosition = Vector3.zero;
            prefabNode.m_PrefabList.Enqueue(prefab);
        }
    }
Example #8
0
 /// <summary>
 /// 实体死亡
 /// </summary>
 /// <param name="entityID"></param>
 /// <param name="t"></param>
 public void OnEntityDead(int entityID, ENTITY_TYPE t)
 {
     if (entityID == CurrentSelectedID ||
         entityID == EntityFactory.MainHeroID)
     {
         CurrentSelectedID = -1;
         ChangeBossBloodTarget(-1);
     }
     if (t == ENTITY_TYPE.TYPE_MONSTER)
     {
         if (m_BloodMap.ContainsKey(entityID))
         {
             CacheBlood(m_BloodMap[entityID]);
         }
         if (BossBloodEntityTable.ContainsKey(entityID))
         {
             BossBloodProityList.Remove(BossBloodEntityTable[entityID]);
             BossBloodEntityTable.Remove(entityID);
         }
         EntityLeaveBossBloodDistance(entityID);
     }
     if (t == ENTITY_TYPE.TYPE_PLAYER_ROLE)
     {
         SetDead(entityID, true);
     }
 }
Example #9
0
    /// <summary>
    /// 创建一个头顶名称
    /// </summary>
    /// <param name="entry">实体</param>
    /// <param name="entryId">实体ID</param>
    /// <param name="text">内容</param>
    /// <param name="col">颜色</param>
    /// <returns></returns>
    public static TopName CreateTopName(GameObject entry, int entryId, string text, Color col)
    {
        if (SFGFxMovieManager.Instance == null)
        {
            Trace.LogError("SFGFxMovieManager没有初始化,请不要在Awake或Start中创建!");
            return(null);
        }

        if (!bInit)
        {
            Trace.LogError("GfxLableManager必须初始化!");
            return(null);
        }
        //有可能TopNameMovie还没有创建完成.
        if (TopNameMovie.Instance == null)
        {
            //Trace.LogError("TopNameMovie尚未创建完成,请等待创建完成后再调用。");
            return(null);
        }
        if (m_TopNameMap.ContainsKey(entryId))
        {
            Trace.LogWarning(entryId + "已经有头顶名,返回已有的实例");

            return(m_TopNameMap[entryId]);
        }

        U3D_Render.EntityView objev = EntityFactory.getEntityViewByID(entryId);
        if (!objev.IsValid)
        {
            Trace.LogWarning("实体视图无效!id=" + entryId);
            return(null);
        }
        ENTITY_TYPE entityType = objev.Type;

        MovieNode trs = new MovieNode();


        TopName t = GetTopName(ref trs);

        if (t == null)
        {
            return(t);
        }
        t.Init(entry, entryId, text, col);
        t.CreateBillBorad();
        t.ChangeMovieNode(trs);
        m_TopNameMap.Add(entryId, t);
        index++;
        ChangeMask(EntityFactory.getEntityViewByID(entryId), true);

        //if (!go)
        //{
        //    go = GameObject.CreatePrimitive(PrimitiveType.Plane);

        //    go.renderer.material.SetTexture("_MainTex", TopNameMovie.TopNameRenderTexture);
        //}

        return(t);
    }
    /// <summary>
    /// 获取血条
    /// </summary>
    /// <param name="entity_Type"></param>
    /// <param name="isHero"></param>
    /// <param name="moveNode"></param>
    /// <returns></returns>
    static GfxBlood GetBlood(ENTITY_TYPE entity_Type, bool isHero, ref MovieNode moveNode)
    {
        GfxBlood gb   = null;
        string   name = m_entiyTypeMap[entity_Type];

        if (isHero) //主角直接创建
        {
            if (!AllocBloodPos(entity_Type, ref moveNode))
            {
                //Debug.LogWarning("Movie空间不足,最多只能容纳:" + MaxColCount * MaxRowCount + "个血条!!");
                return(null);
            }

            name = PlayerSelfBloodAS3RefrenceName;
            gb   = CreateBloodInstance(name);

            return(gb);
        }

        if (!OptimitzedControlPlane.Instance.EnityCreateOptimize)
        {
            if (!AllocBloodPos(entity_Type, ref moveNode))
            {
                //Debug.LogWarning("Movie空间不足,最多只能容纳:" + MaxColCount * MaxRowCount + "个血条!!");
                return(null);
            }
            gb = CreateBloodInstance(name);
            return(gb);
        }

        if (!m_CacheBlood.ContainsKey(entity_Type))
        {
            moveNode = new MovieNode();
            return(gb);
        }
        else
        {
            Queue <GfxBlood> m_CacheList = m_CacheBlood[entity_Type];
            if (m_CacheList.Count > 0)
            {
                gb = m_CacheList.Dequeue();
                gb.SetEnable(true);
                moveNode = gb.movieNode;
            }
            else
            {
                if (!AllocBloodPos(entity_Type, ref moveNode))
                {
                    //Debug.LogWarning("Movie空间不足,最多只能容纳:" + MaxColCount * MaxRowCount + "个血条!!");
                    return(null);
                }
                gb = CreateBloodInstance(name);
            }
        }
        return(gb);
    }
Example #11
0
 public GameEntity(Vector2 position, TextureMap map, ENTITY_TYPE type)
 {
     mPosition = position;
     mVelocity = Vector2.Zero;
     mMidPoint = new Vector2(mPosition.X + map.width / 2, mPosition.Y + map.height / 2);
     mTexture = map;
     mHealth = 50;
     mType = type;
     mAlive = true;
 }
Example #12
0
 public GameEntity(Vector2 position, Vector2 velocity, TextureMap map, ENTITY_TYPE type)
 {
     mPosition = position;
     mVelocity = velocity;
     mMidPoint = new Vector2(mPosition.X + map.width / 2, mPosition.Y + map.height / 2);
     mTexture = map;
     mHealth = Constants.MAX_PLAYER_HEALTH;
     mType = type;
     mAlive = true;
 }
Example #13
0
 public GameEntity(Vector2 position, Vector2 velocity, TextureMap map, ENTITY_TYPE type, int health = 100)
 {
     mPosition = position;
     mVelocity = velocity;
     mMidPoint = new Vector2(mPosition.X + map.width / 2, mPosition.Y + map.height / 2);
     mTexture = map;
     mHealth = health;
     mType = type;
     mAlive = true;
 }
Example #14
0
    /// <summary>
    /// 为血条分配一个位置,分配失败,则表示Movie已经满了。
    /// </summary>
    /// <param name="t"></param>
    /// <returns></returns>
    private static bool AllocBloodPos(ENTITY_TYPE t, ref MovieNode btr)
    {
        if (m_entiySizeMap.ContainsKey(t))
        {
            Vector2 BloodSize = m_entiySizeMap[t];
            btr.isValid = false;
            if (UnUsedMovieNodeList.Count > 0)
            {
                MovieNode bt = UnUsedMovieNodeList.Dequeue();
                btr.RowIndex = bt.RowIndex;
                btr.ColIndex = bt.ColIndex;

                btr.start.x = MovieCell_Width * bt.RowIndex;
                btr.start.y = MovieCell_Height * bt.ColIndex;

                btr.end.x = btr.start.x + BloodSize.x;
                btr.end.y = btr.start.y + BloodSize.y;
                btr.vSize = BloodSize;

                btr.isValid = true;
            }
            else
            {
                btr         = new MovieNode();
                btr.start.x = MovieCell_Width * CurrentRowIndex;
                btr.start.y = MovieCell_Height * CurrentColIndex;

                btr.end.x = btr.start.x + BloodSize.x;
                btr.end.y = btr.start.y + BloodSize.y;
                btr.vSize = BloodSize;


                btr.RowIndex = CurrentRowIndex;
                btr.ColIndex = CurrentColIndex;

                CurrentRowIndex++;
                if (CurrentRowIndex >= MaxRowCount)
                {
                    CurrentColIndex++;
                    if (CurrentColIndex >= MaxColCount)
                    {
                        return(false);
                    }
                    CurrentRowIndex = 0;
                }

                btr.isValid = true;
            }
            return(true);
        }

        return(false);
    }
Example #15
0
 /// <summary>
 /// 实体复活
 /// </summary>
 /// <param name="entityID"></param>
 /// <param name="t"></param>
 public void OnEntityRelive(int entityID, ENTITY_TYPE t)
 {
     if (t == ENTITY_TYPE.TYPE_PLAYER_ROLE)
     {
         if (entityID == EntityFactory.MainHeroID)
         {
             //BossBlood.SetEnable(true);
             bossBloodTarget = EntityFactory.MainHero.transform;
         }
         SetDead(entityID, false);
     }
 }
Example #16
0
    /// <summary>
    /// 实体死亡
    /// </summary>
    /// <param name="entityID"></param>
    public static void OnEntityDead(int entityID, ENTITY_TYPE t)
    {
        if (Movie.GetSingleton <GfxBloodMovie>() == null)
        {
            return;
        }
        if (entityID == CurrentSelectedID ||
            entityID == EntityFactory.MainHeroID)
        {
            CurrentSelectedID = -1;
            ChangeBossBloodTarget(-1);
        }

        //怪物
        if (t == ENTITY_TYPE.TYPE_MONSTER)
        {
            if (m_BloodMap.ContainsKey(entityID))
            {
                if (OptimitzedControlPlane.Instance.EnityCreateOptimize)
                {
                    CacheBlood(m_BloodMap[entityID]);
                }
                else
                {
                    Destroy(m_BloodMap[entityID]);
                }
            }

            if (BossBloodEntityTable.ContainsKey(entityID))
            {
                BossBloodProityList.Remove(BossBloodEntityTable[entityID]);
                BossBloodEntityTable.Remove(entityID);
            }

            EntityLeaveBossBloodDistance(entityID);
        }

        //玩家
        if (t == ENTITY_TYPE.TYPE_PLAYER_ROLE)
        {
            if (m_BloodMap.ContainsKey(entityID))
            {
                //如果是主角,特殊处理一下
                if (entityID == EntityFactory.MainHeroID)
                {
                    bPlayerDead = true;
                    m_BloodMap[entityID].SetPlayerVisible(false);
                }
                m_BloodMap[entityID].SetVisible(false);
            }
        }
    }
Example #17
0
    private EntityView GetSelectedEntity(int _nEntityID, ENTITY_TYPE _eEntityType)
    {
        switch (_eEntityType)
        {
        case ENTITY_TYPE.TYPE_PLAYER_ROLE:
            return(EntityFactory.getPlayerViewByID(_nEntityID));

        case ENTITY_TYPE.TYPE_MONSTER:
            return(EntityFactory.getMonsterViewByID(_nEntityID));

        default:
            return(EntityFactory.getEntityViewByID(_nEntityID));
        }
    }
Example #18
0
 /// <summary>
 /// Checks an inventories permissions against an entities' flags to see if it has access to the inventory.
 /// </summary>
 /// <param name="entity_flags"></param>
 /// <param name="inventory_flags"></param>
 /// <returns></returns>
 public bool CheckInventoryPermissions(ENTITY_TYPE entity_flags, INVENTORY_MODIFIERS inventory_flags)
 {
     //Check if the inventory is machine accessible and if the entity is a machine.
     if (INV_UTILITY.HasTag(inventory_flags, INVENTORY_MODIFIERS.MachineAccessible) &&
         ENTITY_UTILITY.HasTag(entity_flags, ENTITY_TYPE.Machine))
     {
         return(true);
     }// Check if the inventory is player accessible and if the entity is a player.
     else if (INV_UTILITY.HasTag(inventory_flags, INVENTORY_MODIFIERS.PlayerAccessible) &&
              ENTITY_UTILITY.HasTag(entity_flags, ENTITY_TYPE.Player))
     {
         return(true);
     }
     //If it reaches this point then we don't have the right permissions.
     return(false);
 }
Example #19
0
        public GameObject Instantiate(ENTITY_TYPE entityType)
        {
            if (OrginalObj != null)
            {
                GameObject o = OrginalObj.InstanceMainRes();
                if (o)
                {
                    o.name = entityType.ToString() + "--cache";
                    o.transform.SetParent(PrefabCacheRoot.transform);
                    o.SetActive(false);
                }
                return(o);
            }

            return(null);
        }
 public ActionResult saveSendingEntityTypes(List <string> toBeDeleted, List <string> toBeAdded)
 {
     try
     {
         CMSEntities m_context = new CMSEntities();
         m_context.Configuration.ProxyCreationEnabled = false;
         List <string> failedToDelete = new List <string>();
         if (toBeAdded != null)
         {
             foreach (var item in toBeAdded)
             {
                 var query = m_context.ENTITY_TYPE.Where(a => a.NAME_AR == item);
                 if (!query.Select(q => q.NAME_AR).Contains(item))
                 {
                     m_context.ENTITY_TYPE.Add(new ENTITY_TYPE {
                         NAME_AR = item
                     });
                 }
             }
             m_context.SaveChanges();
         }
         if (toBeDeleted != null)
         {
             foreach (var item in toBeDeleted)
             {
                 try
                 {
                     ENTITY_TYPE s = (ENTITY_TYPE)m_context.ENTITY_TYPE.Where(a => a.NAME_AR == item).First();
                     m_context.ENTITY_TYPE.Remove(s);
                     m_context.SaveChanges();
                 }
                 catch (Exception ex)
                 {
                     failedToDelete.Add(item);
                 }
             }
         }
         var current = (from row in m_context.ENTITY_TYPE select row.NAME_AR).ToList();
         return(Json(new object[] { failedToDelete, current }, JsonRequestBehavior.AllowGet));
     }
     catch (Exception)
     {
         throw;
     }
 }
Example #21
0
    public void Init(int id, GameObject host, int cam, ENTITY_TYPE bt)
    {
        lastpixelPos = Vector3.zero;
        m_entry      = host;
        m_ID         = id;
        m_TempValue  = 0;
        m_level      = 1;
        isHero       = id == EntityFactory.MainHeroID;
        if (host)
        {
            m_EntryProperty = host.GetComponent <CreatureProperty>();
        }
        bloodType = bt;
        SetCamType(cam);

        setPrafabPer();

        nColor = GameLogicAPI.getCanseckillHpColor(getMonsterSchemeId());
    }
Example #22
0
    /// <summary>
    /// 根据实体ID控制上帝视角 位置
    /// </summary>
    /// <param name="_nGodEyeState">0:进入上帝视角状态;1:移动上帝视角位置</param>
    /// <param name="_nEntityID"></param>
    /// <param name="_eEntityType"></param>
    public void GodEyeBySelectedEntity(int _nEntityID, ENTITY_TYPE _eEntityType = ENTITY_TYPE.TYPE_PLAYER_ROLE)
    {
        EntityView evSelectedEntity = null;

        evSelectedEntity = GetSelectedEntity(_nEntityID, _eEntityType);

        if (evSelectedEntity == null)
        {
            return;
        }

        if (SoldierCamera.MainInstance.cameraMode != SoldierCamera.CameraControlMode.GodEyeControl)
        {
            EnterGodEyeMode(evSelectedEntity.gameObject.transform.position);
            return;
        }

        ChangeGodEyePos(evSelectedEntity.gameObject.transform.position);
    }
Example #23
0
 /// <summary>
 /// Compares an entites crafting flags and compares it with the craft flags on a recipe
 /// to see if the entity is capable of crafting that recipe.
 /// </summary>
 /// <param name="entity_flags"></param>
 /// <param name="craft_flags"></param>
 /// <returns></returns>
 public bool isCompatibleCraftingType(ENTITY_TYPE entity_flags, CRAFT_TYPE craft_flags)
 {
     if (ENTITY_UTILITY.HasTag(entity_flags, ENTITY_TYPE.Player) &&
         CRAFT_UTILITY.HasTag(craft_flags, CRAFT_TYPE.HandCraftable))
     {
         return(true);
     }
     else if (ENTITY_UTILITY.HasTag(entity_flags, ENTITY_TYPE.AutoCrafter) &&
              CRAFT_UTILITY.HasTag(craft_flags, CRAFT_TYPE.MachineCraftable))
     {
         return(true);
     }
     else if (ENTITY_UTILITY.HasTag(entity_flags, ENTITY_TYPE.Smelter) &&
              CRAFT_UTILITY.HasTag(craft_flags, CRAFT_TYPE.Smelting))
     {
         return(true);
     }
     return(false);
 }
Example #24
0
    /// <summary>
    /// Checks if the given items can be placed in a given entity based on its flags.
    /// If the entity is storage, it can take any items so can just return true immediately.
    /// Else, we have to check if the possible recipe is valid for the given machine.
    /// </summary>
    /// <returns></returns>
    public bool isItemPlacementValid(List <GenericItem> item_list, ENTITY_TYPE entity_flags)
    {
        //Return true immediately if it is just storage.
        if (ENTITY_UTILITY.HasTag(entity_flags, ENTITY_TYPE.Storage))
        {
            return(true);
        }

        //Get all the valid recipes since this entity should be able to craft and isn't just storage.
        List <GenericRecipe> VALID_RECIPES = GetValidRecipes(item_list, entity_flags);

        //If the count is greater than 0, return true;
        if (VALID_RECIPES.Count > 0)
        {
            return(true);
        }
        else
        {
            return(false);
        }
    }
Example #25
0
    /// <summary>
    /// 加载预制体
    /// </summary>
    /// <param name="entityType">实体类型(是怪物,还是人物..)</param>
    /// <param name="strPrefabPath">模型路径</param>
    /// <returns>是否成功</returns>
    public static bool LoadPrefab(ENTITY_TYPE entityType, string strPrefabPath)
    {
        ResNode obj = AssetBundleManager.GetAssets(AssetType.Asset_Prefab, strPrefabPath);

        if (obj != null)
        {
            if (m_PrefabMap.ContainsKey(entityType))
            {
                return(true);
            }

            InsertToMap(obj, entityType);

            return(true);
        }
        else
        {
            Trace.LogError("加载预制体失败,类型:" + entityType + ",路径:" + strPrefabPath);
            return(false);
        }
    }
Example #26
0
 /// <summary>
 /// 实体复活
 /// </summary>
 /// <param name="entityID"></param>
 public static void OnEntityRelive(int entityID, ENTITY_TYPE t)
 {
     //玩家
     if (t == ENTITY_TYPE.TYPE_PLAYER_ROLE)
     {
         if (m_BloodMap.ContainsKey(entityID))
         {
             //如果是主角,特殊处理一下
             if (entityID == EntityFactory.MainHeroID)
             {
                 bPlayerDead = false;
                 if (bPlayerBloodVisible)
                 {
                     m_BloodMap[entityID].SetPlayerVisible(true);
                 }
                 return;
             }
             m_BloodMap[entityID].SetVisible(true);
         }
     }
 }
Example #27
0
 /// <summary>
 /// 实体死亡
 /// </summary>
 /// <param name="entityID"></param>
 public static void OnEntityDead(int entityID, ENTITY_TYPE t)
 {
     if (Movie.GetSingleton <TopNameMovie>() == null)
     {
         return;
     }
     if (m_TopNameMap.ContainsKey(entityID))
     {
         //目前仅仅针对怪物
         if (t == ENTITY_TYPE.TYPE_MONSTER)
         {
             if (OptimitzedControlPlane.Instance.EnityCreateOptimize)
             {
                 CacheTopName(m_TopNameMap[entityID]);
             }
             else
             {
                 Destroy(m_TopNameMap[entityID]);
             }
         }
     }
 }
Example #28
0
    /// <summary>
    /// Given a list of items, returns all the valid recipes regardless of item count.
    /// The input list does not care for how much of each item there is.
    /// This is for helping with deciding if an item should be moved by automation.
    /// Also checks crafting types the entity is capable of doing.
    /// </summary>
    /// <param name="item_list"></param>
    /// <returns></returns>
    public List <GenericRecipe> GetValidRecipes(List <GenericItem> item_list, ENTITY_TYPE entity_info)
    {
        List <GenericRecipe> VALID_RECIPES = new List <GenericRecipe>();

        //Copy the recipe list.
        foreach (GenericRecipe RECIPE in RECIPE_LIST)
        {
            VALID_RECIPES.Add(RECIPE);
        }

        //For all valid recipes.
        for (int i = 0; i < VALID_RECIPES.Count; i++)
        {
            //For every item in our item list.
            foreach (GenericItem item in item_list)
            {
                //Debug.Log("Index: " + i + " Length: " + VALID_RECIPES.Count);
                //If the recipe doesn't require a given item, or the recipe type is incompatable with entity capabilities
                if (!VALID_RECIPES[i].RequireItem(item) || !isCompatibleCraftingType(entity_info, VALID_RECIPES[i].FLAGS))
                {
                    //Remove the recipe from the list.
                    VALID_RECIPES.Remove(VALID_RECIPES[i]);

                    //Update the index so it isn't broken.
                    if (i != VALID_RECIPES.Count)
                    {
                        i--;
                    }
                    else if (i == VALID_RECIPES.Count)
                    {
                        break;
                    }
                }
            }
        }
        return(VALID_RECIPES);
    }
Example #29
0
        public bool CreateRagdoll(RDSetup setup)
        {
            // No entity, setup or body count overflow - bypass function.

            if (setup == null || setup.BodySetup.Count > Bf.BoneTags.Count)
            {
                return false;
            }

            var result = true;

            // If ragdoll already exists, overwrite it with new one.

            if (Bt.BtJoints.Count > 0)
            {
                result = DeleteRagdoll();
            }

            // Setup bodies.
            Bt.BtJoints.Clear();
            // update current character animation and full fix body to avoid starting ragdoll partially inside the wall or floor...
            UpdateCurrentBoneFrame(Bf, Transform);
            Bt.NoFixAll = false;
            Bt.NoFixBodyParts = 0x00000000;
#if NOPE
            int map_size = m_bf.animations.model->collision_map.size();             // does not works, strange...
            m_bf.animations.model->collision_map.size() = m_bf.animations.model->mesh_count;
            fixPenetrations(nullptr);
            m_bf.animations.model->collision_map.size() = map_size;
#else
            FixPenetrations(Vector3.Zero);
#endif

            for(var i = 0; i < setup.BodySetup.Count; i++)
            {
                // TODO: First check useless?
                if(i >= Bf.BoneTags.Count || Bt.BtBody[i] == null)
                {
                    result = false;
                    continue; // If body is absent, return false and bypass this body setup.
                }

                var inertia = BulletSharp.Math.Vector3.Zero;
                var mass = setup.BodySetup[i].Mass;

                BtEngineDynamicsWorld.RemoveRigidBody(Bt.BtBody[i]);

                Bt.BtBody[i].CollisionShape.CalculateLocalInertia(mass, out inertia);
                Bt.BtBody[i].SetMassProps(mass, inertia);

                Bt.BtBody[i].UpdateInertiaTensor();
                Bt.BtBody[i].ClearForces();

                Bt.BtBody[i].LinearFactor = BulletSharp.Math.Vector3.One;
                Bt.BtBody[i].AngularFactor = BulletSharp.Math.Vector3.One;

                Bt.BtBody[i].SetDamping(setup.BodySetup[i].Damping[0], setup.BodySetup[i].Damping[1]);
                Bt.BtBody[i].Restitution = setup.BodySetup[i].Restitution;
                Bt.BtBody[i].Friction = setup.BodySetup[i].Friction;

                Bt.BtBody[i].SetSleepingThresholds(RD_DEFAULT_SLEEPING_THRESHOLD, RD_DEFAULT_SLEEPING_THRESHOLD);

                if(Bf.BoneTags[i].Parent == null)
                {
                    var r = GetInnerBBRadius(Bf.BoneTags[i].MeshBase.BBMin, Bf.BoneTags[i].MeshBase.BBMax);
                    Bt.BtBody[i].CcdMotionThreshold = 0.8f * r;
                    Bt.BtBody[i].CcdSweptSphereRadius = r;
                }
            }

            UpdateRigidBody(true);
            for(var i = 0; i < Bf.BoneTags.Count; i++)
            {
                BtEngineDynamicsWorld.AddRigidBody(Bt.BtBody[i]);
                Bt.BtBody[i].Activate();
                Bt.BtBody[i].LinearVelocity = Speed.ToBullet();
                if (i < Bt.GhostObjects.Count && Bt.GhostObjects[i] != null)
                {
                    BtEngineDynamicsWorld.RemoveCollisionObject(Bt.GhostObjects[i]);
                    BtEngineDynamicsWorld.AddCollisionObject(Bt.GhostObjects[i], CollisionFilterGroups.None, CollisionFilterGroups.None);
                }
            }

            // Setup constraints.
            Bt.BtJoints.Resize(setup.JointSetup.Count);

            for(var i = 0; i < setup.JointSetup.Count; i++)
            {
                if(setup.JointSetup[i].BodyIndex >= Bf.BoneTags.Count || Bt.BtBody[setup.JointSetup[i].BodyIndex] == null)
                {
                    result = false;
                    break; // If body 1 or body 2 are absent, return false and bypass this joint.
                }

                var localA = new Transform();
                var localB = new Transform();
                var btB = Bf.BoneTags[setup.JointSetup[i].BodyIndex];
                var btA = btB.Parent;
                if(btA == null)
                {
                    result = false;
                    break;
                }
#if NOPE
                localA.setFromOpenGLMatrix(btB->transform);
                localB.setIdentity();
#else
                Helper.SetEulerZYX(ref localA.Basis, setup.JointSetup[i].Body1Angle);
                //localA.Origin = setup.JointSetup[i].Body1Offset;
                localA.Origin = btB.Transform.Origin;

                Helper.SetEulerZYX(ref localB.Basis, setup.JointSetup[i].Body2Angle);
                //localB.Origin = setup.JointSetup[i].Body2Offset;
                localB.Origin = Vector3.Zero;
#endif

                switch(setup.JointSetup[i].JointType)
                {
                    case RDJointSetup.Type.Point:
                        Bt.BtJoints[i] = new Point2PointConstraint(Bt.BtBody[btA.Index], Bt.BtBody[btB.Index],
                            localA.Origin.ToBullet(), localB.Origin.ToBullet());
                        break;

                        case RDJointSetup.Type.Hinge:
                        var hingeC = new HingeConstraint(Bt.BtBody[btA.Index], Bt.BtBody[btB.Index], ((Matrix4) localA).ToBullet(),
                            ((Matrix4) localB).ToBullet());
                        hingeC.SetLimit(setup.JointSetup[i].JointLimit[0], setup.JointSetup[i].JointLimit[1], 0.9f, 0.3f, 0.3f);
                        Bt.BtJoints[i] = hingeC;
                        break;

                    case RDJointSetup.Type.Cone:
                        var coneC = new ConeTwistConstraint(Bt.BtBody[btA.Index], Bt.BtBody[btB.Index], ((Matrix4)localA).ToBullet(),
                            ((Matrix4)localB).ToBullet());
                        coneC.SetLimit(setup.JointSetup[i].JointLimit[0], setup.JointSetup[i].JointLimit[1], setup.JointSetup[i].JointLimit[2], 0.9f, 0.3f, 0.7f);
                        Bt.BtJoints[i] = coneC;
                        break;
                }

                Bt.BtJoints[i].SetParam(ConstraintParam.StopCfm, setup.JointCfm, -1);
                Bt.BtJoints[i].SetParam(ConstraintParam.StopErp, setup.JointErp, -1);

                Bt.BtJoints[i].DebugDrawSize = 64.0f;
                BtEngineDynamicsWorld.AddConstraint(Bt.BtJoints[i], true);
            }

            if(!result)
            {
                DeleteRagdoll(); // PARANOID: Clean up the mess, if something went wrong.
            }
            else
            {
                TypeFlags |= ENTITY_TYPE.Dynamic;
            }
            return result;
        }
Example #30
0
        public bool DeleteRagdoll()
        {
            if (Bt.BtJoints.Count == 0)
                return false;

            for (var i = 0; i < Bt.BtJoints.Count; i++)
            {
                if(Bt.BtJoints[i] != null)
                {
                    BtEngineDynamicsWorld.RemoveConstraint(Bt.BtJoints[i]);
                    Bt.BtJoints[i] = null;
                }
            }

            for(var i = 0; i < Bf.BoneTags.Count; i++)
            {
                BtEngineDynamicsWorld.RemoveRigidBody(Bt.BtBody[i]);
                Bt.BtBody[i].SetMassProps(0, BulletSharp.Math.Vector3.Zero);
                BtEngineDynamicsWorld.AddRigidBody(Bt.BtBody[i], CollisionFilterGroups.KinematicFilter, CollisionFilterGroups.AllFilter);
                if(i < Bt.GhostObjects.Count && Bt.GhostObjects[i] != null)
                {
                    BtEngineDynamicsWorld.RemoveCollisionObject(Bt.GhostObjects[i]);
                    BtEngineDynamicsWorld.AddCollisionObject(Bt.GhostObjects[i], CollisionFilterGroups.CharacterFilter, CollisionFilterGroups.AllFilter);
                }
            }

            Bt.BtJoints.Clear();

            TypeFlags &= ~ENTITY_TYPE.Dynamic;

            return true;
        }
Example #31
0
 public TypeId(ENTITY_TYPE type, uint id)
 {
     Type = type;
     Id   = id;
 }
Example #32
0
    /// <summary>
    /// 创建一个Blood,返回一个GfxBlood实例,失败返回null
    /// </summary>
    /// <param name="entityID">实体ID</param>
    /// <param name="Host">实体</param>
    /// <param name="campType">阵营类型</param>
    /// <param name="CurValue">当前值</param>
    /// <param name="MaxValue">最大值</param>
    public static GfxBlood CreateBlood(U3D_Render.EntityView objev, int entityID, GameObject Host, int campType, int CurValue = 100, int MaxValue = 100)
    {
        if (SFGFxMovieManager.Instance == null)
        {
            Trace.LogError("SFGFxMovieManager没有初始化,请不要在Awake中创建!");
            return(null);
        }
        if (!bInit)
        {
            Trace.LogError("GfxBloodManager必须初始化!");
            return(null);
        }
        //有可能GfxBloodMovie还没有创建完成.
        if (GfxBloodMovie.Instance == null)
        {
            //Trace.LogError("GfxBloodMovie尚未创建完成,请等待创建完成后再调用。");
            return(null);
        }

        CreateBossBlood();

        if (!objev.IsValid)
        {
            Trace.LogWarning("实体视图无效!id=" + entityID);
            return(null);
        }

        if (m_BloodMap.ContainsKey(entityID))
        {
            Trace.LogWarning(entityID + "已经有血条,返回已有的实例");
            GfxBlood gba = m_BloodMap[entityID];
            return(gba);
        }

        CurValue = Mathf.Clamp(CurValue, 0, MaxValue);


        ENTITY_TYPE entityType = objev.Type;

        if (!m_entiyTypeMap.ContainsKey(entityType))
        {
            Trace.LogWarning(entityID + "找不到实体类型:" + entityType + "使用怪物类型代替,请在GfxBloodManager::Init()中添加");
            entityType = ENTITY_TYPE.TYPE_MONSTER;
        }

        //按照策划要求,目前不创建己方小兵血条,其他己方物体不变
        if (objev.Flag == (int)EWarMonsterExec.EWME_Soldier && campType == (int)GFxCampManager.GFxCampTpye.CT_Friend)
        {
            return(null);
        }

        MovieNode trs = new MovieNode();
        GfxBlood  gb  = GetBlood(entityType, entityID == EntityFactory.MainHeroID, ref trs);

        if (null == gb)
        {
            return(null);
        }
        gb.Init(entityID, Host, campType, entityType);
        gb.CreateBillBorad();
        //获取最大值和当前值
        MaxValue = objev.Property.GetNumProp(ENTITY_PROPERTY.PROPERTY_MAX_HP);
        CurValue = objev.Property.GetNumProp(ENTITY_PROPERTY.PROPERTY_HP);

        gb.SetMaxValue(MaxValue);
        gb.SetCurValue(CurValue);

        //设置一下血量数字信息
        string bloodInfo = CurValue + "/" + MaxValue;

        gb.SetBloodInfo(bloodInfo);

        //设置血量数字信息是否显示,通过读取本地配置文件
        gb.SetBloodInfoVisible(bBloodInfoVisible);

        //判断一下如果是主角,则通过读取本地配置文件,设置主角血量是否显示
        if (entityID == EntityFactory.MainHeroID)
        {
            //读取本地配置文件,获取玩家血条是否需要显示
            bPlayerBloodVisible = ASpeedGame.Data.GameSettingsXml.GameSettingsXmlManager.Instance.GameSettingsModel.showPlayerBlood.AValue;
            gb.SetPlayerVisible(bPlayerBloodVisible);
        }

        gb.ChangeMovieNode(trs);
        m_BloodMap.Add(entityID, gb);
        ChangeMask(objev, true);
        //if (!go)
        //{
        //    go = GameObject.CreatePrimitive(PrimitiveType.Plane);

        //    go.GetComponent<Renderer>().sharedMaterial.SetTexture("_MainTex", GfxBloodMovie.BloodRenderTexture);
        //}
        if (entityType == ENTITY_TYPE.TYPE_PLAYER_ROLE && entityID != EntityFactory.MainHeroID)
        {
            setHeroProperty(objev);
        }
        return(gb);
    }
Example #33
0
 public static InteractStateModel Create(ENTITY_TYPE parentType, uint parentId) => Create(Type, parentType, parentId);
Example #34
0
 /// <summary>
 /// 构造函数
 /// </summary>
 /// <param name="id">实体ID</param>
 /// <param name="type">实体类型</param>
 public EntityView(ENTITY_ID id, ENTITY_TYPE type)
 {
     //Trace.LogWarning("EntityView::EntityView() id=" + m_id.ToString() + ", ThreadID=" + Thread.CurrentThread.ManagedThreadId);
     m_id   = id;
     m_type = type;
 }
Example #35
0
 public TargetEntity(ENTITY_TYPE type, uint id)
 {
     this.Type = type;
     this.Id   = id;
 }