public void init() { ///这个要替换其他的btn。 bool visible = Utils.equal(DataManager.inst.systemSimple, "testBtn", 1); this.voiceBtn.gameObject.SetActive(visible); ClientRunTime clientRunTime = FightMain.instance.selection; clientRunTime.registerClientView(this); this.rank.init(Tools.FindChild2("topRightLayer/scoreRankLayer", this.gameObject)); //TODO:断网重连 这个不知道会不会有问题。 可能有坑。 先留着。 this.initCards(); GameObject scoreGame = Tools.FindChild2("topRightLayer/teamBallsLayer", this.gameObject); if (clientRunTime.mapData.isTeam) { this.scoreView = scoreGame.GetComponent <RadishScoreView>(); if (null == this.scoreView) { this.scoreView = scoreGame.AddComponent <RadishScoreView>(); } scoreView.init(clientRunTime); scoreGame.SetActive(true); } else { scoreGame.SetActive(false); } clientRunTime.addListener(EventConstant.END, (e) => { GameObject finish = ResFactory.createObject <GameObject>(ResFactory.getOther("finish")); finish.transform.SetParent(this.transform, false); TimerManager.inst.Add(2, 1, (t) => { Destroy(finish); }); }); this.videoChange(); clientRunTime.addListener(EventConstant.LOGIC_COMPLETE, (e) => { if (null != clientRunTime.localPlayer.reviveAction) { this.playerReliveText.enabled = true; //TODO:改成语言配置 string str = string.Format("复活中...{0:F1}", clientRunTime.localPlayer.reviveAction.time / 1000f); this.playerReliveText.text = str; } else { this.playerReliveText.enabled = false; } }); }
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); }
public void init(GameObject parent, int index) { this.go = ResFactory.loadPrefab("scoreRankItem"); this.go = ResFactory.createObject <GameObject>(this.go); this.bg = this.go.transform.FindChild("bgImage").GetComponent <Image>(); this.nameText = this.go.transform.FindChild("nameText").GetComponent <Text>(); this.scoreText = this.go.transform.FindChild("scoreText").GetComponent <Text>(); this.indexText = this.go.transform.FindChild("indexText").GetComponent <Text>(); this.go.transform.SetParent(parent.transform, false); }
public void playVoice(string voiceName, float delay = 0f) { AudioClip audioClip = ResFactory.loadVoiceClip(voiceName); GameObject go = ResFactory.loadPrefab("audio"); go = ResFactory.createObject <GameObject>(go); go.name = voiceName; AudioSource audioSource = go.GetComponent <AudioSource>(); audioSource.clip = audioClip; audioSource.PlayDelayed(delay); ResFactory.Destroy(go, audioClip.length + delay); go.transform.SetParent(this.audioController.transform); }
void Awake() { GameObject go = ResFactory.loadPrefab("card"); for (int i = 0, len = this._initCards.Length; i < len; i++) { Card card = ResFactory.createObject <GameObject>(go).GetComponent <Card>(); card.index = i; this._initCards[i] = card; card.transform.SetParent(Tools.FindChild2("bottomLayer", this.gameObject).transform, false); card.transform.localPosition = new Vector3(230 + i * 130, 75, 0); } this.testBtnChange.onClick.AddListener(() => { this.testBtn.SetActive(!this.testBtn.activeSelf); }); this.voiceBtn.onClick.AddListener(() => { this.testCanvas.SetActive(!this.testCanvas.activeSelf); }); }
public static GameObject getCacheEffect(string name, ClientRunTime clientRunTime, bool visible = true) { GameObject result = null; if (!effectMap.ContainsKey(name)) { effectMap[name] = new List <GameObject>(); } List <GameObject> gameObjects = effectMap[name]; if (gameObjects.Count > 0) { int len = gameObjects.Count - 1; result = gameObjects[len]; gameObjects.RemoveAt(len); } else { result = ResFactory.getEffect(name); if (null == result) { Debug.Log("没有资源" + name); } result = ResFactory.createObject <GameObject>(result); result.AddComponent <CacheEffect>().clientRunTime = clientRunTime; result.name = name; AutoDestroy auto = result.GetComponent <AutoDestroy>(); if (auto != null) { auto.onlyDeactivate = true; } } if (visible) { result.gameObject.SetActive(true); //有些要延迟生效 就不给他visible等于true。 } return(result); }
private void updateBtn() { while (this.selects.Count != 0) { Destroy(this.selects[0].gameObject); this.selects.RemoveAt(0); } ; try { string str = this.readFile(); if (str == "") { return; } FightMain.ccccc = ""; Dictionary <string, object> dic = JsonMapper.ToObject <Dictionary <string, object> >(str); foreach (string key in dic.Keys) { L_Button btn = ResFactory.createObject <L_Button>(this.select_btn); ((RectTransform)btn.transform).sizeDelta = new Vector2(80, 50); btn.transform.SetParent(this.transform); btn.transform.localPosition = new Vector3(-52 + (this.selects.Count % 2) * 100, 69 + (int)(this.selects.Count / 2) * 100, 0); btn.SetText(key); this.selects.Add(btn); new TestSelecteItem(key, btn).addListener("change", (e) => { string uid = e.data.ToString().Split('_')[0]; int teamIndex = Convert.ToInt32(e.data.ToString().Split('_')[1]); FightMain.instance.autoRunClient.startFight((object[])dic[uid], uid, teamIndex, ConfigConstant.MODE_TEST_WATCH); }); } } catch (Exception e) { this.logDebug("解析错误"); } }
/// 获得一个物体的边缘提示GO public GameObject getEdgeHintGameObject(int index) { return(ResFactory.createObject <GameObject>(prefabs[index])); }
public override void init() { this.mainScale = Convert.ToSingle(((Dictionary <string, object>)ConfigConstant.scoreConfig[this._playerEntity.fightResult.scoreLevel])["mainScale"]); this.avatar = ResFactory.createObject <AvatarView>(ResFactory.instance.avatar); this.avatar.init(Tools.FindChild2("ship", this.skewBody.gameObject).transform, this._playerEntity); base.init(); /****************************加入边界************************/ this.scene.edgeHintController.addFightObject(this._playerEntity.teamIndex == this.clientRunTime.teamIndex ? 1 : 2, this._fightEntity); /****************************名字************************/ //Biggo修改 this.nameText.text = this._playerEntity.name; this.nameText.color = this._playerEntity.getTeamColor(0); ResFactory.setHeadSprite(this._playerEntity.headUrl, Tools.FindChild2("personEarth/Canvas/faceImage/Image", this.gameObject).GetComponent <Image>(), this._playerEntity.uid); /****************************outLine************************/ Tools.FindChild2("personEarth/Canvas/nameText", this.gameObject).GetComponent <Outline>().effectColor = this._playerEntity.getTeamColor(1); /****************************frameImage************************/ Tools.FindChild2("personEarth/Canvas/frameImage", this.gameObject).GetComponent <Image>().color = this._playerEntity.getTeamColor(2); /****************************装备************************/ for (int i = 0, len = ConfigConstant.PART_COUNT; i < len; i++) { this.parts.Add(new PartSlider(this, i)); } this.shipEntryTween(true); /****************************事件************************/ //TODO:这个是否要与callView dead进行融合??? this._fightEntity.addListener(EventConstant.ALIVED, (e) => { this.gameObject.SetActive(this._fightEntity.alived); this.changeMove(1); if (!this._fightEntity.alived) { //死亡了。。。 this.clientRunTime.addEffect("bangDead", this._fightEntity.position); } else { this.avatar.reset(); this.shipEntryTween(true); this.clientRunTime.addEffect("bangBorn", this._fightEntity.position); for (int i = 0; i < ConfigConstant.PART_COUNT; i++) { this.parts[i].updatePart(); } } }); this._playerEntity.addListener(EventConstant.LEVEL_CHANGE, (MainEvent e) => { this.mainScale = Convert.ToSingle(((Dictionary <string, object>)ConfigConstant.scoreConfig[this._playerEntity.fightResult.scoreLevel])["mainScale"]); this.shipEntryTween(false); Dictionary <string, object> scoreDic = (Dictionary <string, object>)e.data; if ((int)scoreDic["newLevel"] > (int)scoreDic["oldLevel"]) { this.addEffect("bangScore"); this.doAvatarAnimation("score"); } }); this._playerEntity.addListener(EventConstant.KILL_PLAYER, (MainEvent e) => { List <ClientPlayerEntity> players = (List <ClientPlayerEntity>)e.data; this.scene.addKillRadio(players[0], players[1]); }); this.gameObject.SetActive(this._fightEntity.alived); }
protected virtual TeamBall createBall() { return(ResFactory.createObject <GameObject>(ResFactory.getOther("teamBall")).GetComponent <TeamBall>()); }
public void init(string id, int type, PartAction partData, Transform parent, ClientPlayerEntity playerEntity, float scoreScale) { this.type = type; this._playerEntity = playerEntity; this._map = (ClientRunTime)this._playerEntity.map; //不同id 更换 if (this.id != id) { this.id = id; if (null != this.gameObject) { LeanTween.cancel(this.gameObject); GameObject.Destroy(this.gameObject); } this.gameObject = ResFactory.getShip(id); //翅膀 if (this.type == 1) { GameObject goLeft = ResFactory.createObject <GameObject>(this.gameObject); goLeft.name = "left"; //右 GameObject goRight = ResFactory.createObject <GameObject>(this.gameObject); goRight.transform.localScale = new Vector3(1, -1, 1); goRight.name = "right"; this.gameObject = new GameObject(); goLeft.transform.SetParent(this.gameObject.transform, false); goRight.transform.SetParent(this.gameObject.transform, false); } else { this.gameObject = ResFactory.createObject <GameObject>(this.gameObject); } this.gameObject.name = id; this.gameObject.transform.SetParent(parent, false); if (type == 5 - 1) { this.gameObject.transform.localPosition = new Vector3(0, 0, 1); } else { this.gameObject.transform.localPosition = new Vector3(); } this._material = ViewUtils.getMaterial(this.gameObject, ViewConstant.SHIP_SHADER_NAME); ViewUtils.changeColor(this._material, (Dictionary <string, object>)ViewConstant.shipConfig[this._playerEntity.shipColorId]); } if (partData != this.partData) { this.resetPart(scoreScale, scoreScale, scoreScale); } //两个装备不等 直接重置装备。可以是同id替换 if (null != partData && this.partData != partData) { //如果装备立刻启用的话 在一进入可能瞬间装备就生效了! if (partData.alived) { this.partStartHandler(null); } else { this._color = ViewUtils.cloneColor(ViewConstant.SHADER_COLOR_WARM); this._material.color = this._color; ViewUtils.setEnable(this.gameObject, false); /*************************启用用装备******************************/ partData.addListener(EventConstant.ALIVED, partStartHandler); } /*************************受伤闪红******************************/ partData.addListener(EventConstant.HURT, (e) => { ViewUtils.colorInOutMaterial(this.gameObject, this._material, ViewConstant.SHADER_COLOR_RED, ViewConstant.SHADER_COLOR_STANDARD, 0.05f, 0.3f); }); } this.partData = partData; }
protected override TeamBall createBall() { return(ResFactory.createObject <GameObject>(ResFactory.loadPrefab("radishBall")).GetComponent <RadishBall>()); }