public FightObject createFightObject(FightEntity entity) { GameObject go = null; FightObject fightObject = null; switch (entity.type) { case ConfigConstant.ENTITY_LOOP_BEAN: // go = ResFactory.instance.getBean(((LoopBeanEntity)entity).itemType); fightObject = go.GetComponent <Bean>(); break; case ConfigConstant.ENTITY_PLAYER: if (((PlayerEntity)entity).uid == this.uid) { go = ResFactory.createObject <GameObject>(ResFactory.instance.player); fightObject = go.AddComponent <PlayerSelf>(); } else { go = ResFactory.createObject <GameObject>(ResFactory.instance.player); fightObject = go.AddComponent <Enemy>(); } break; case ConfigConstant.ENTITY_BULLET: fightObject = ResFactory.getBullet(entity.data["resId"].ToString(), this); break; case ConfigConstant.ENTITY_PRICE_BEAN: go = ResFactory.instance.getBean(((PriceBeanEntity)entity).itemType); fightObject = go.GetComponent <Bean>(); break; case ConfigConstant.ENTITY_CALL: go = ResFactory.createObject <GameObject>(ResFactory.instance.call); fightObject = go.GetComponent <CallView>(); break; case ConfigConstant.ENTITY_BARRIER: go = ResFactory.loadPrefab(entity.data["resId"].ToString()); go = ResFactory.createObject <GameObject>(go); fightObject = go.GetComponent <Barrier>(); break; case ConfigConstant.ENTITY_RADISH: go = ResFactory.loadPrefab("radish"); go = ResFactory.createObject <GameObject>(go); fightObject = go.AddComponent <Radish>(); break; } entity.viewData.view = entity.view = fightObject; fightObject.fightEntity = entity; return(fightObject); }
/// <summary>开启学习技能线程</summary> public void SkillLearnOk(Int64 user_id, Int64 rid, int skillid, Int64 time) { try { var token = new CancellationTokenSource(); # if DEBUG time = 60000; #endif Object obj = new FightObject { user_id = user_id, rid = rid, skillid = skillid }; Task.Factory.StartNew(m => { var t = m as FightObject; if (t == null) { return; } var key = t.GetKey(); Variable.CD.AddOrUpdate(key, false, (k, v) => false); SpinWait.SpinUntil(() => { var b = Convert.ToBoolean(Variable.CD[key]); return(b); }, Convert.ToInt32(time)); }, obj, token.Token) .ContinueWith((m, n) => { var lo = n as FightObject; if (lo == null) { token.Cancel(); return; } PushLearn(lo.user_id, lo.rid, lo.skillid); //移除全局变量 var key = lo.GetKey(); bool r; Variable.CD.TryRemove(key, out r); token.Cancel(); }, obj, token.Token); }
public void Tip(FightObject fight) { StartCoroutine(PlayClip(AudioClips.Instance.DrunkenManTipLines.Find(x => x.Name == fight.name).Line)); }