// void Awake () { // Init (); // } public void init(FightEntity entity) { this.fightEntity = entity; this.clientRunTime = (ClientRunTime)entity.map; this.localPositionV2 = new Vector2(); this.localScaleV3 = new Vector3(1, 1, 1); this.materialList = new List <Material> (); Material material; //一次性取出所有 MeshRenderer ParticleSystem Renderer[] renderers = this.GetComponentsInChildren <Renderer>(); foreach (Renderer renderer in renderers) { material = renderer.material; renderer.material = material; materialList.Add(material); } imageArr = this.GetComponentsInChildren <Image>(); if (this.fightEntity.type == ConfigConstant.ENTITY_PLAYER) { Image image = Tools.FindChild2("Canvas/faceImage", this.gameObject).transform.GetChild(0).GetComponent <Image> (); ClientPlayerEntity player = (ClientPlayerEntity)entity; ResFactory.setHeadSprite(player.headUrl, image, player.uid); //Sprite spr = ((Player)player.view).faceSprite; //image.sprite = spr; } lastAlpha = 1f; ChangeAlpha(0); }
public void clearFight() { ResFactory.clear(); Utils.clearObject(this.server); Utils.clearObject(this._selection); ResFactory.enable = true; this._selection = null; this.server = null; }
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 virtual void init(ClientRunTime clientRunTime) { this._clientRunTime = clientRunTime; this.teamController = this._clientRunTime.refereeController.teamController; //this.teamController.addListener this.resetBalls(); this.updateBallsPoint(); this.updateBallsScale(); this.initColor(); }
public override int GetHashCode() { var result = 17; unchecked { // ReSharper disable NonReadonlyMemberInGetHashCode result = result * 37 + (int)Recurrence; result = result * 37 + UtcRunTime.GetHashCode(); result = result * 37 + ClientRunTime.GetHashCode(); // ReSharper restore NonReadonlyMemberInGetHashCode } return(result); }
public void addUser(string uid, int teamIndex, int index = 0) { if (null == this._selection) { ClientRunTime client = new ClientRunTime(); client.teamIndex = teamIndex; client.scene = this.scene; client.uid = uid; client.init(); client.index = index; this._selection = client; } if (FightMain.isLocal) { this.server.netWork.addUser(uid, new Dictionary <string, object> { { "cardGroup", PlayerData.instance.cardGroup.ToArray() }, { "teamIndex", teamIndex } }); } }
//————————————————————————————特效子弹—————————————————————————————————— public static Bullet getBullet(string name, ClientRunTime clientRunTime) { GameObject go = getCacheEffect(name, clientRunTime, false); Bullet result = go.GetComponent <Bullet>(); if (null == result) { result = go.AddComponent <Bullet>(); } else { TimerManager.inst.Add(0, 1, (float t) => { if (!result.fightEntity.cleared) { result.gameObject.SetActive(true); result.init(); } }); } result.bulletName = name; return(result); }
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); }
void Start() { //TODO:写成这样是因为 这个类的生存周期就是战斗本身。 FightMain.instance.addListener(EventConstant.PLAYER_IN, (MainEvent e) => { init(); }); this.setTest(); //重新设置下卡牌的样子。 FightMain.instance.addListener(EventConstant.CLIENT_CHANGE, (MainEvent e) => { Dictionary <string, object> dic = (Dictionary <string, object>)e.data; ClientRunTime oldClient = (ClientRunTime)dic["old"]; ClientRunTime newClient = (ClientRunTime)dic["new"]; if (null != oldClient && null != oldClient.localPlayer) { oldClient.localPlayer.cardGroup.removeListener(EventConstant.CHANGE, initCards); } if (null != newClient && null != newClient.localPlayer) { this.initCards(); } }); }
public override void init(ClientRunTime clientRunTime) { base.init(clientRunTime); this.radishController.addListener(EventConstant.ADD_POINT, (e) => { int team = (int)e.data; this.ballArray[team].updateTeamPoint(this.teamController.teamPointArray[team]); this.updateBallsScale(); }); this.radishController.radish.addListener(EventConstant.GAIN_RADISH, (e) => { this.updateBallsGain(); this.updateBallsScale(); }); this.radishController.radish.addListener(EventConstant.DROP_RADISH, (e) => { this.updateBallsGain(); this.updateBallsScale(); }); this.updateBallsGain(); this.radishController.addListener(EventConstant.NOTIFY, this.notityHandler); this.addRadioGuide("配合队友抢夺方块"); }
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; }
public PartView(ClientRunTime map) { this._map = map; this._map.registerClientView(this); }
public void init(ClientRunTime clientRunTime) { this._clientRunTime = clientRunTime; this._clientRunTime.registerClientView(this); }