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; }