// 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 onUpdate(float rate) { ClientPlayerEntity player = this._clientRunTime.localPlayer; if (null != player) { if (player.alived) { this.showPointer(); if (!player.joystickAngle.isZero) { rotationV3.z = Mathf.LerpAngle(rotationV3.z, Convert.ToSingle(Math2.radianToAngle(player.joystickAngle.angle)), 0.5f); } positionV3.x = Mathf.Lerp(positionV3.x, Convert.ToSingle(player.steeringForce.length) * 0.025f + Mathf.Sqrt(((Player)player.view).mainScale) * 0.9f + 0.08f, 0.5f); pointerRota.localRotation = Quaternion.Euler(rotationV3); pointerPos.localPosition = positionV3; } else { this.hidePointer(); } } else { hidePointer(); } }
public RadioInfo(ClientPlayerEntity player, string type) { this.player1 = player; Dictionary <string, object> dic = (Dictionary <string, object>)RadioConfig.othersConfig[type]; initData(dic); }
public void init(Transform parent, ClientPlayerEntity playerEntity) { this._transform.SetParent(parent, false); this._transform.localRotation = Quaternion.Euler(180, 0, 0); this._playerEntity = playerEntity; ((ClientRunTime)this._playerEntity.map).registerClientView(this); this._playerEntity.partGroup.addListener(EventConstant.PART_CHANGE, (e) => { this.updateView(); }); }
public override PlayerEntity createUser(Dictionary <string, object> data) { PlayerEntity player = base.createUser(data); if (player.uid == this.uid) { this.localPlayer = player as ClientPlayerEntity; if (this == FightMain.instance.selection) { FightMain.instance.DispatchEventWith(EventConstant.PLAYER_IN); } } return(player); }
public void changeIndexText(int i, ClientPlayerEntity player) { this.go.SetActive(true); this.indexText.text = (i + 1).ToString(); this.nameText.text = player.name; this.nameText.color = player.getTeamColor(0); this.scoreText.text = (player.fightResult.score / ConfigConstant.SCORE_UNIT).ToString(); int colorIndex = player.teamIndex; if (player.isLocalPlayer) { bg.color = COLOR_SELF; } else { bg.color = COLOR_OTHER; } }
public override FightEntity createFightEntity(int type, int netId = -1) { FightEntity entity = null; switch (type) { case ConfigConstant.ENTITY_LOOP_BEAN: // entity = new ClientBeanEntity(this, netId); break; case ConfigConstant.ENTITY_PLAYER: entity = new ClientPlayerEntity(this, netId); break; case ConfigConstant.ENTITY_BULLET: entity = new ClientBulletEntity(this, netId); break; case ConfigConstant.ENTITY_PRICE_BEAN: entity = new ClientPriceBeanEntity(this, netId); break; case ConfigConstant.ENTITY_CALL: entity = new ClientCallEntity(this, netId); break; case ConfigConstant.ENTITY_BARRIER: entity = new ClientBarrierEntity(this, netId); break; case ConfigConstant.ENTITY_RADISH: entity = new ClientRadishEntity(this, netId); break; } return(entity); }
///广播杀人事态 public void addKillRadio(ClientPlayerEntity player1, ClientPlayerEntity player2) { this.radioController.addKillRadio(player1, player2); }
///广播抢萝卜事态 public void addRadishRadio(ClientPlayerEntity playerEntity, string type) { this.radioController.addRadishRadio(playerEntity, type); }
///加入一条击杀播报 public void addKillRadio(ClientPlayerEntity player1, ClientPlayerEntity player2) { RadioInfo radio = new RadioInfo(player1, player2); this.radiolist.Add(radio); }
///加入一条抢萝卜播报 public void addRadishRadio(ClientPlayerEntity playerEntity, string type) { RadioInfo radio = new RadioInfo(playerEntity, type); radiolist.Add(radio); }
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 void changeRadishEdgeHint (int team) { // //清理子容器 // ViewUtils.clearChildren(this.transform); // GameObject gameObject; // if (team != 0) { // gameObject = this.clientRunTime.scene.edgeHintController.getEdgeHintGameObject(team); // gameObject.transform.SetParent(this.transform, false); // } //} public void updatePosition() { ClientPlayerEntity player = this.clientRunTime.localPlayer; float radarDistance = isRadarMax ? this.clientRunTime.mapData.widthHalf : Convert.ToSingle(player.getProperty(ConfigConstant.PROPERTY_RADAR)); Vector2D aimLogicDelta = Collision.realPosition(player.position, this.fightEntity.position, this.clientRunTime.mapData).deltaPos; double logicDistance = aimLogicDelta.length; double logicAbsX = Math.Abs(aimLogicDelta.x); double logicAbsY = Math.Abs(aimLogicDelta.y); if (!isEternal && !fightEntity.alived) { this.gameObject.SetActive(false); return; } if (logicDistance > radarDistance || (logicAbsX < EdgeHintController.LOGIC_EDGE_X && logicAbsY < EdgeHintController.LOGIC_EDGE_Y)) { //超出雷达范围,或直接可以看到,不显示提示 this.gameObject.SetActive(false); } else { double angle = aimLogicDelta.angle; Vector2D v2d = aimLogicDelta.clone(); // Debug.Log (angle); double angleDeltaAbs = Math.Abs(angle); //根据相距距离较长的轴,缩放,越远越小,最大为1 double tempScale; //逻辑 if (angleDeltaAbs <= EdgeHintController.VERTEX_ANGLE || angleDeltaAbs >= Math.PI - EdgeHintController.VERTEX_ANGLE) { //左右边超出 tempScale = EdgeHintController.LOGIC_EDGE_X / logicAbsX; v2d.y *= tempScale; v2d.x = v2d.x > 0 ? EdgeHintController.LOGIC_EDGE_X : -EdgeHintController.LOGIC_EDGE_X; } else { //上下边超出, logicAbsY != 0 tempScale = EdgeHintController.LOGIC_EDGE_Y / logicAbsY; v2d.x *= tempScale; v2d.y = v2d.y > 0 ? EdgeHintController.LOGIC_EDGE_Y : -EdgeHintController.LOGIC_EDGE_Y; } tempScale = Math.Pow(tempScale, 0.8); //v2d转为视图含义 v2d.x = v2d.x / EdgeHintController.LOGIC_EDGE_X * EdgeHintController.VIEW_EDGE_X; v2d.y = v2d.y / EdgeHintController.LOGIC_EDGE_Y * EdgeHintController.VIEW_EDGE_Y; localPositionV2.x = Convert.ToSingle(v2d.x); localPositionV2.y = Convert.ToSingle(v2d.y); //根据相距距离较长的轴,缩放,越远越小,临近时最大为1 localScaleV3.x = localScaleV3.y = localScaleV3.z = Convert.ToSingle(tempScale); //改变透明度,很近时很小,很远时很小 double temp = logicDistance / radarDistance; double alpha; if (temp > 0.8f) { //太远 // alpha = (1f - temp) * 4f+0.2f; alpha = (1f - temp) * 5f; } else if (tempScale > 0.6f) { //太近 // alpha = (1f - tempScale) * 2f+0.2f; alpha = (1f - tempScale) * 2f; // Debug.Log ("太近tempScale:"+tempScale+" alpha:"+alpha); } else { alpha = 1f; } ChangeAlpha(Convert.ToSingle(alpha)); this.transform.localScale = localScaleV3; //首次进来 让他直接跳到目标点。 if (!this.gameObject.activeSelf) { this.update(1); } //将提示坐标映射到屏幕边缘 this.gameObject.SetActive(true); } }
public RadioInfo(ClientPlayerEntity player1, ClientPlayerEntity player2) { this.player1 = player1; this.player2 = player2; initKill(); }