private async Task SetTanksInfo(string tanksInfoFileName, AccountInformationPipelineContextData contextData) { List <WotAccountTanksStatistics> tanksInfo = null; using (var r = new StreamReader(tanksInfoFileName)) { var json = await r.ReadToEndAsync(); var tanks = JsonConvert.DeserializeObject <ResponseBody <Dictionary <string, List <WotAccountTanksStatistics> > > >(json); tanksInfo = tanks.Data?.Values.FirstOrDefault(); } if (tanksInfo == null) { throw new ApplicationException($"Can not read tanks info from '{tanksInfoFileName}'"); } contextData.Tanks = new List <TankInfo>(); contextData.TanksHistory = new Dictionary <long, TankInfoHistory>(); tanksInfo.OrderByDescending(t => t.LastBattleTime).ToList().ForEach(tank => { var tankInfo = new TankInfo(tank.AccountId, tank.TankId); _mapper.Map(tank, tankInfo); contextData.Tanks.Add(tankInfo); var stat = new TankInfoHistory(tank.AccountId, tank.TankId, tank.LastBattleTime); _mapper.Map(tank.All, stat); contextData.TanksHistory[stat.TankId] = stat; }); }
public void Setup() { m_PlayerName = PlayerPrefs.GetString("Player" + m_PlayerNumber); //Input m_FireButton = "Fire" + m_PlayerNumber; m_MovementAxisName = "Vertical" + m_PlayerNumber; m_TurnAxisName = "Horizontal" + m_PlayerNumber; m_Skill = "Skill" + m_PlayerNumber; m_TankInfo = m_Instance.GetComponent <TankInfo>(); if (!m_TankInfo) { return; } m_Movement = m_TankInfo.tankMovement; m_Shooting = m_TankInfo.tankShooting; m_CanvasGameObject = m_TankInfo.tankCanvas; m_TankEffects = m_TankInfo.tankEffects; m_TankHealth = m_TankInfo.tankHealth; m_SkillBase = m_TankInfo.skill; m_TankInfo.id = m_PlayerNumber; m_ColoredPlayerText = "<color=#" + ColorUtility.ToHtmlStringRGB(m_PlayerColor) + ">" + m_PlayerName + "</color>"; MeshRenderer[] renderers = m_Instance.GetComponentsInChildren <MeshRenderer>(); for (int i = 0; i < renderers.Length; i++) { renderers[i].material.color = m_PlayerColor; } }
public async Task Invoke(IOperationContext context, Func <IOperationContext, Task>?next) { var contextData = context.Get <AccountInformationPipelineContextData>(); var tanksInfo = await _wargamingApi.GetPlayerAccountTanksInfo(context.Request.AccountId, context.Request.RealmType, context.Request.RequestLanguage); if (tanksInfo == null) { _logger.LogInformation( $"Tanks not found for AccountId {context.Request.AccountId} and {context.Request.RealmType} realm"); return; } contextData.Tanks = new List <TankInfo>(); contextData.TanksHistory = new Dictionary <long, TankInfoHistory>(); tanksInfo.OrderByDescending(t => t.LastBattleTime).ToList().ForEach(tank => { var tankInfo = new TankInfo(tank.AccountId, tank.TankId); _mapper.Map(tank, tankInfo); contextData.Tanks.Add(tankInfo); var stat = new TankInfoHistory(tank.AccountId, tank.TankId, tank.LastBattleTime); _mapper.Map(tank.All, stat); contextData.TanksHistory[stat.TankId] = stat; }); if (next != null) { await next.Invoke(context); } }
protected override void AddEffect(TankInfo tank) { if (damage > 0f) { tank.tankEffects.AddEffect(new Effect_Burn(burnDuration, burnDelay, damage * burnDamagePercentMaxDamge / m_MaxDamage)); } }
public virtual void DoUpdate(TankInfo tankInfo, float deltaTime) { countDownDelay -= deltaTime; duration -= deltaTime; if (countDownDelay <= 0f) { countDownDelay = delay; DoAffect(tankInfo); } }
protected virtual void OnTriggerEnter(Collider other) { CreateObject(); // Collect all the colliders in a sphere from the shell's current position to a radius of the explosion radius. Collider[] colliders = Physics.OverlapSphere(transform.position, m_ExplosionRadius, m_TankMask); // Go through all the colliders... for (int i = 0; i < colliders.Length; i++) { // ... and find their rigidbody. TankInfo target = colliders[i].GetComponent <TankInfo>(); // If they don't have a rigidbody, go on to the next collider. if (!target) { continue; } // Add an explosion force. target.rigidbody.AddExplosionForce(m_ExplosionForce, transform.position, m_ExplosionRadius); // If there is no TankHealth script attached to the gameobject, go on to the next collider. if (!target.tankHealth) { continue; } // Calculate the amount of damage the target should take based on it's distance from the shell. damage = CalculateDamage(target.rigidbody.position); // Deal this damage to the tank. target.tankHealth.TakeDamage(damage); AddEffect(target); } // Unparent the particles from the shell. //m_ExplosionParticles.transform.parent = null; m_ExplosionParticles.gameObject.transform.SetPositionAndRotation(transform.position, transform.rotation); m_ExplosionParticles.gameObject.SetActive(true); // Play the particle system. m_ExplosionParticles.Play(); // Play the explosion sound effect. m_ExplosionAudio.Play(); //// Once the particles have finished, destroy the gameobject they are on. //ParticleSystem.MainModule mainModule = m_ExplosionParticles.main; //Destroy(m_ExplosionParticles.gameObject, mainModule.duration); // Destroy the shell. gameObject.SetActive(false); }
private void Instance_OnUpdateTank(TankInfo tankinfo) { this.transform.position = Vector3.Lerp(this.transform.position, new Vector3(tankinfo.px, tankinfo.py, tankinfo.pz), 0.1f); this.transform.rotation = new Quaternion(tankinfo.rw, tankinfo.rx, tankinfo.ry, tankinfo.rz); this.GetComponentInChildren <Transform>().GetComponentsInChildren <Transform>()[5].rotation = new Quaternion(tankinfo.childRw, tankinfo.childRx, tankinfo.childRy, tankinfo.childRz); this.transform.Rotate(new Vector3(0, 180, 0)); this.transform.localEulerAngles = new Vector3(0, -this.transform.localEulerAngles.y, 0); if (tankinfo.isShoot == 1) { tankshoot.ShootControl(true); } }
public override void UpdateFixed() { curr_TankInfos.Clear(); Collider[] colliders = Physics.OverlapSphere(transform.position, radius, layerMask); int i = 0; for (i = 0; i < colliders.Length; i++) { // ... and find their rigidbody. TankInfo target = colliders[i].GetComponent <TankInfo>(); // If they don't have a rigidbody, go on to the next collider. if (!target) { continue; } curr_TankInfos.Add(target); } i = 0; while (i < prev_TankInfos.Count) { if (curr_TankInfos.IndexOf(prev_TankInfos[i]) == -1) { prev_TankInfos[i].tankEffects.RemoveEffect(new Virtual_Effect(idEffects[i])); prev_TankInfos.RemoveAt(i); idEffects.RemoveAt(i); } else { i++; } } i = 0; while (i < curr_TankInfos.Count) { if (prev_TankInfos.IndexOf(curr_TankInfos[i]) == -1) { prev_TankInfos.Add(curr_TankInfos[i]); Effect_PoisonZone effect_PoisonZone = new Effect_PoisonZone(delayPoison, damagePerDelayPoison); idEffects.Add(effect_PoisonZone.id); curr_TankInfos[i].tankEffects.AddEffect(effect_PoisonZone); } else { i++; } } }
//trans player info to tank info TankInfo PlayerToTankInfo(Player p) { TankInfo t = new TankInfo() { camp = p.camp, id = p.id, hp = p.hp, x = p.x, y = p.y, z = p.z, ex = p.ex, ey = p.ey, ez = p.ez, }; return(t); }
//玩家数据转成TankInfo public TankInfo PlayerToTankInfo(Player player) { TankInfo tankInfo = new TankInfo(); tankInfo.camp = player.camp; tankInfo.id = player.id; tankInfo.hp = player.hp; tankInfo.x = player.x; tankInfo.y = player.y; tankInfo.z = player.z; tankInfo.ex = player.ex; tankInfo.ey = player.ey; tankInfo.ez = player.ez; return(tankInfo); }
public void GetStatus(int _gameId, int _player, float _time, int _num) { TankInfo info = null; sqlConn = new MySqlConnection(); MySqlCommand cmd = new MySqlCommand(); cmd.CommandText = string.Format("SELECT * FROM status WHERE gameId='{0}' AND player='{1}' AND gameTime>'{2}'", _gameId, _player, _time); int i = 0; Vector3 temp = new Vector3(); try { sqlConn.Open(); MySqlDataReader reader = cmd.ExecuteReader(); while (reader.Read() && i < _num) { temp.x = reader.GetFloat(reader.GetOrdinal("posX")); temp.y = reader.GetFloat(reader.GetOrdinal("posY")); temp.z = reader.GetFloat(reader.GetOrdinal("posZ")); info.Position = temp; temp.x = reader.GetFloat(reader.GetOrdinal("rotX")); temp.y = reader.GetFloat(reader.GetOrdinal("rotY")); temp.z = reader.GetFloat(reader.GetOrdinal("rotZ")); info.EularAngles = temp; temp.x = reader.GetFloat(reader.GetOrdinal("tRotX")); temp.y = reader.GetFloat(reader.GetOrdinal("tRotY")); temp.z = reader.GetFloat(reader.GetOrdinal("tRotZ")); info.TurretEularAngles = temp; temp.x = reader.GetFloat(reader.GetOrdinal("vX")); temp.y = reader.GetFloat(reader.GetOrdinal("vY")); temp.z = reader.GetFloat(reader.GetOrdinal("vZ")); info.Speed = temp; info.Health = reader.GetInt16(reader.GetOrdinal("hp")); } } catch (MySqlException e) { Debug.Log("[DataMgr]execution" + e.Message); return; } finally { sqlConn.Close(); } }
// 必存,0.06秒检查一次 public void StoreStatus(TankInfo _tankInfo) { string cmdstr = string.Format("insert into status set gameId='{0}', gameTime='{1}', player='{2}', flag='{3}', posX='{4}', " + "posY='{5}', posZ='{6}', rotX='{7}', rotY='{8}', rotZ='{9}', " + "tRotX='{10}', tRotY='{11}', tRotZ='{12}', vX='{13}', vY='{14}', vZ='{15}', hp='{16}';", gameId, (float)PhotonNetwork.time, PhotonNetwork.player.ID, (int)PhotonNetwork.player.AllProperties["flag"], _tankInfo.Position.x, _tankInfo.Position.y, _tankInfo.Position.z, _tankInfo.EularAngles.x, _tankInfo.EularAngles.y, _tankInfo.EularAngles.z, _tankInfo.TurretEularAngles.x, _tankInfo.TurretEularAngles.y, _tankInfo.TurretEularAngles.z, _tankInfo.Speed.x, _tankInfo.Speed.y, _tankInfo.Speed.z, _tankInfo.Health); try { Execute(cmdstr); return; } catch (MySqlException e) { Debug.Log("[DataMgr]execution" + e.Message); return; } }
//产生坦克 public static void GenerateTank(TankInfo tankInfo) { //GameObject string objName = "Tank_" + tankInfo.id; GameObject tankObj = new GameObject(objName); //AddComponent BaseTank tank = null; if (tankInfo.id == GameMain.id) { tank = tankObj.AddComponent <CtrlTank>(); } else { tank = tankObj.AddComponent <SyncTank>(); } //camera if (tankInfo.id == GameMain.id) { CameraFollow cf = tankObj.AddComponent <CameraFollow>(); } //属性 tank.camp = tankInfo.camp; tank.id = tankInfo.id; tank.hp = tankInfo.hp; //pos rotation Vector3 pos = new Vector3(tankInfo.x, tankInfo.y, tankInfo.z); Vector3 rot = new Vector3(tankInfo.ex, tankInfo.ey, tankInfo.ez); tank.transform.position = pos; tank.transform.eulerAngles = rot; //init if (tankInfo.camp == 1) { tank.Init("tankPrefab"); } else { tank.Init("tankPrefab2"); } //列表 AddTank(tankInfo.id, tank); }
public async Task ShouldSaveTanksThatLastDateIsGreaterThenInDatabase() { _contextData.NeedToSaveData = true; var context = new OperationContext(new AccountRequest(AccountId, Realm, Language)); context.AddOrReplace(_contextData); int outdatedTanksCount = 3; int outdatedTanksIndex = 0; foreach (var tank in _contextData.Tanks) { if (outdatedTanksIndex < outdatedTanksCount) { var tankInfo = new TankInfo { TankInfoId = new TankInfoKey { TankId = tank.TankId, AccountId = tank.AccountId, }, LastBattleTime = tank.LastBattleTime - 1 }; WargamingDataAccessorMock.Setup(d => d.ReadTankInfo(tank.AccountId, tank.TankId)) .ReturnsAsync(tankInfo); outdatedTanksIndex++; } else { WargamingDataAccessorMock.Setup(d => d.ReadTankInfo(tank.AccountId, tank.TankId)) .ReturnsAsync(tank); } } await _operation.Invoke(context, null); var tanksCount = _contextData.Tanks.Count; WargamingDataAccessorMock.Verify(d => d.AddOrUpdateTankInfo(It.IsAny <TankInfo>()), Times.Exactly(outdatedTanksCount)); WargamingDataAccessorMock.Verify(d => d.AddTankInfoHistory(It.IsAny <TankInfoHistory>()), Times.Exactly(outdatedTanksCount)); }
protected void DoDamage() { TankInfo target = hit.collider.GetComponent <TankInfo>(); // If they don't have a rigidbody, go on to the next collider. if (!target) { return; } // If there is no TankHealth script attached to the gameobject, go on to the next collider. if (!target.tankHealth) { return; } float damage = CalculateDamage(target.rigidbody.position); // Deal this damage to the tank. target.tankHealth.TakeDamage(damage); }
private void TankSelection(int index) { //button manage if (_currentIndex == 0 || GameData.playerState.boughtTanks.Contains(_currentIndex + 1)) { chooseButton.gameObject.SetActive(true); upgradeButton.gameObject.SetActive(true); buyButton.gameObject.SetActive(false); } else { chooseButton.gameObject.SetActive(false); upgradeButton.gameObject.SetActive(false); buyButton.gameObject.SetActive(true); buyButton.GetComponentInChildren <TextMeshProUGUI>().text = tankPrice[_currentIndex].ToString(); } TankInfo tankInfo = tankInfos[index]; PlayerInfoPanel.Instance.DataUpdate(tankInfo.name, tankInfo.power); }
protected void DoDamage() { // Collect all the colliders in a sphere from the shell's current position to a radius of the explosion radius. Collider[] colliders = Physics.OverlapSphere(hit.point, m_Radius, layer); // Go through all the colliders... for (int i = 0; i < colliders.Length; i++) { // ... and find their rigidbody. TankInfo target = colliders[i].GetComponent <TankInfo>(); // If they don't have a rigidbody, go on to the next collider. if (!target) { continue; } // Add an explosion force. target.rigidbody.AddExplosionForce(m_ExplosionForce, transform.position, m_Radius); // If there is no TankHealth script attached to the gameobject, go on to the next collider. if (!target.tankHealth) { continue; } // Calculate the amount of damage the target should take based on it's distance from the shell. float damage = CalculateDamage(target.rigidbody.position); // Deal this damage to the tank. target.tankHealth.TakeDamage(damage); } canAffect = false; doDisable = true; }
public void HandleMessage(string message) { Debug.Log("HandleMessage:" + message); int target = message.IndexOf(":"); string tag = message.Substring(0, target); string content = message.Substring(target + 1); switch (tag) { case "register": if (OnRegisterResult != null) { OnRegisterResult(content); } break; case "login": if (OnLoginResult != null) { OnLoginResult(content); } break; case "createPlayer": RedayInfo redayinfo = GetData2 <RedayInfo>(content); if (OnCreatePlayer != null) { Debug.Log(content); OnCreatePlayer(redayinfo); } break; case "playerstatus": PlayerInfo player = GetData2 <PlayerInfo>(content); if (OnUpdataPlayer != null) { OnUpdataPlayer(player); } break; case "reday": if (content == "go!" && OnStartResult != null) { OnStartResult(content); } break; case "Tankstatus": Debug.Log(content); TankInfo tankinfo = GetData2 <TankInfo>(content); if (OnUpdateTank != null) { OnUpdateTank(tankinfo); } break; case "createEnemy": Debug.Log("收到创建"); enemyInfo enemyInfo = GetData2 <enemyInfo>(content); if (OnCreateEnemy != null) { OnCreateEnemy(enemyInfo); } break; case "GamePass": if (content == "first") { if (OnGameCount != null) { OnGameCount(content); } NetWorkManage.Instance.SendMessage("CreateEnemy:{\"enemy\":2}"); } else if (content == "second") { if (OnGameCount != null) { OnGameCount(content); } NetWorkManage.Instance.SendMessage("CreateEnemy:{\"enemy\":3}"); } else { SceneManager.LoadScene("Scenes/win"); } break; case "EnemyDie": EnemyDie enemydie = GetData2 <EnemyDie>(content); if (OnEnemyDie != null) { OnEnemyDie(enemydie); } break; case "EnemyBoom": EnemyDie enemyboom = GetData2 <EnemyDie>(content); if (OnEnemyBoom != null) { OnEnemyBoom(enemyboom); } break; case "PlayerUpdata": PlayerUpdata playerupdata = GetData2 <PlayerUpdata>(content); if (OnPlayerUpdata != null) { OnPlayerUpdata(playerupdata); } break; case "Enemytarget": NavMeshInfo navMeshInfo = GetData2 <NavMeshInfo>(content); if (OnWayPoint != null) { OnWayPoint(navMeshInfo); } break; case "MoneyUpdata": MoneyUpdata money = GetData2 <MoneyUpdata>(content); if (OnMoneyUpdata != null) { OnMoneyUpdata(money); } break; case "GameOver": SceneManager.LoadScene("Scenes/GameOver"); break; default: break; } }
public virtual void DoOnDisable(TankInfo tank) { }
public virtual void DoAffect(TankInfo tankInfo) { }
public TankSyncInfo(int id, TankInfo baseInfo) { Debug.Assert(GamePlayerController.localClient.isServer); this.id = id; this.baseInfo = baseInfo; }
public override void DoAffect(TankInfo tankInfo) { tankInfo.tankHealth.TakeDamage(damagePerDelay); }
void Start() { ThisScript = this; }
protected virtual void AddEffect(TankInfo tank) { }