void OnDestroy() { spriteAnimator = null; spriteAtlasPathArray = null; status = null; }
protected override void Awake() { base.Awake(); TowerStatus status = TowerTable.GetStatus(id); Initialize(status.hp, status.damage, status.attackSpeed); }
public IActionResult Index(string name, string city, string district, TowerType? type, TowerStatus? status, Provider? provider) { IEnumerable<Tower> towers = DB.Towers; if (!string.IsNullOrEmpty(name)) towers = towers.Where(x => x.Name.Contains(name) || name.Contains(x.Name)); if (!string.IsNullOrEmpty(city)) towers = towers.Where(x => x.City.Contains(city) || city.Contains(x.City)); if (!string.IsNullOrEmpty(district)) towers = towers.Where(x => x.District.Contains(district) || district.Contains(x.District)); if (type.HasValue) towers = towers.Where(x => x.Type == type.Value); if (status.HasValue) towers = towers.Where(x => x.Status == status.Value); if (provider.HasValue) towers = towers.Where(x => x.Provider == provider.Value); return PagedView(towers); }
public void InitModel(TowerBaseInfo info, bool isPlay = true) { if (gameObject.activeSelf == false) { gameObject.SetActive(true); } StopAllCoroutines(); gameObject.transform.localPosition = Vector3.zero; status = new TowerStatus(this, 0, info, true); SetAtlas(); if (isPlay && spriteAnimator != null) { spriteAnimator.PlayAnimation(eAnimationType.Type_Lobby_Idle, null); } }
public void Init(TowerPlaceToken token, TowerPlacedInfo info) { if (gameObject.activeSelf == false) { gameObject.SetActive(true); } StopAllCoroutines(); gameObject.transform.localPosition = token.obj.transform.localPosition; status = new TowerStatus(this, token.FloorIndex, info); SetAtlas(); if (TowerManager.Instance != null) { TowerManager.Instance.AddTowerList(this); } StartCoroutine("AttackMode"); }
public void SetTowerStatus(TowerStatus ts, int towerIndex /* 쓸모가 없음.. ts에 정보가 들어있으 */, int groundIndex) { Name = ts.Name; ID = groundIndex; Level = ts.Level; TowerType = ts.TowerType; Attack = ts.Attack; AtkSpd = ts.AtkSpd; SellCost = ts.SellCost; TowerIndex = ts.TowerIndex; UpgradePerDamage = ts.UpgradePerDamage; BulletType = ts.BulletType; Range = ts.Range; BounceDDR = ts.BounceDDR; BulletSpd = ts.BulletSpd; BounceNum = ts.BounceNum; MinDamage = ts.MinDamage; MaxDamage = ts.MaxDamage; UpgradePerMinD = ts.UpgradePerMinD; UpgradePerMaxD = ts.UpgradePerMaxD; SplashRange = ts.SplashRange; CriticalProb = ts.CriticalProb; CriticalMagni = ts.CriticalMagni; RayLength = ts.RayLength; RayDirX = ts.RayDirX; RayDirZ = ts.RayDirZ; DotSustainTime = ts.DotSustainTime; DotDamage = ts.DotDamage; UPDD = ts.UPDD; MaxDotST = ts.MaxDotST; AOSustainTime = ts.AOSustainTime; AODamage = ts.AODamage; UPDAO = ts.UPDAO; MultiNum = ts.MultiNum; MultiRate = ts.MultiRate; CurrUpgradeNum = ts.CurrUpgradeNum; vPosition = ConstructManager.Instance.groundInfoList[groundIndex].position; vPosition.y = 0.0f; }
public static TowerStatus GetStatus(string id) { foreach (var status in instance.statuses) { if (status.id != id) { continue; } TowerStatus s = new TowerStatus(); s.id = status.id; s.isUsed = status.isUsed; s.prefab = status.prefab; s.hp = (int)(status.hp * instance.hp); s.damage = (int)(status.damage * instance.damage); s.cost = status.cost; s.sprite = status.sprite; s.attackSpeed = status.attackSpeed * instance.attackSpeed; s.name = status.name; return(s); } throw new Exception($"{id.ToString().Fill("White")}를 찾을 수 없음"); }
public void SetTowerStatus(TowerStatus ts) { Name = ts.Name; ID = 0; Level = ts.Level; TowerType = ts.TowerType; Attack = ts.Attack; AtkSpd = ts.AtkSpd; SellCost = ts.SellCost; TowerIndex = ts.TowerIndex; UpgradePerDamage = ts.UpgradePerDamage; BulletType = ts.BulletType; Range = ts.Range; BounceDDR = ts.BounceDDR; BulletSpd = ts.BulletSpd; BounceNum = ts.BounceNum; MinDamage = ts.MinDamage; MaxDamage = ts.MaxDamage; UpgradePerMinD = ts.UpgradePerMinD; UpgradePerMaxD = ts.UpgradePerMaxD; SplashRange = ts.SplashRange; CriticalProb = ts.CriticalProb; CriticalMagni = ts.CriticalMagni; RayLength = ts.RayLength; RayDirX = ts.RayDirX; RayDirZ = ts.RayDirZ; DotSustainTime = ts.DotSustainTime; DotDamage = ts.DotDamage; UPDD = ts.UPDD; MaxDotST = ts.MaxDotST; AOSustainTime = ts.AOSustainTime; AODamage = ts.AODamage; UPDAO = ts.UPDAO; MultiNum = ts.MultiNum; MultiRate = ts.MultiRate; CurrUpgradeNum = ts.CurrUpgradeNum; }
//JoaoWeapons public void Init(TowerStatus status) { this.status = new TowerStatus(status.attack_str, status.cooldown_time, status.attack_range, status.health, status.type, status.upgrade_level, status.weapon_attack_range, status.weapon_atack_duration); this.name = status.type.ToString(); this.transform.GetChild(0).GetComponent <Animator>().SetInteger("status", status.upgrade_level); //this.GetComponent<SpriteRenderer>().sprite= Resources.Load<Sprite>(GlobalData.TOWERSPRITEPATHS[status.type][status.upgrade_level]); can_do = true; if (TowerBar == null) { //JoaoBarFollow GameObject Tower_Bars = GameObject.Find("InGame").transform.Find("TD").Find("tower_bars").gameObject; TowerBar = (GameObject)Instantiate(Resources.Load("Prefabs/ObjectBar")); TowerBar.transform.parent = Tower_Bars.transform; TowerBar.GetComponent <ObjectEnergyBar>().Init(this.gameObject); //JoaoBarFollow } }
// 코루틴 . 디비파싱 public void TowerStatusDbParsing(string p) { string Filepath = Application.persistentDataPath + "/" + p; if (!File.Exists(Filepath)) { Debug.LogWarning("File \"" + Filepath + "\" does not exist. Attempting to create from \"" + Application.dataPath + "!/assets/" + p); WWW loadDB = new WWW("jar:file://" + Application.dataPath + "!/assets/" + p); while (!loadDB.isDone) { } File.WriteAllBytes(Filepath, loadDB.bytes); } string connectionString = "URI=file:" + Filepath; // using을 사용함으로써 비정상적인 예외가 발생할 경우에도 반드시 파일을 닫히도록 할 수 있다. using (IDbConnection dbConnection = new SqliteConnection(connectionString)) { dbConnection.Open(); using (IDbCommand dbCmd = dbConnection.CreateCommand()) // EnterSqL에 명령 할 수 있다. { string sqlQuery = "SELECT * FROM TowerStatus"; dbCmd.CommandText = sqlQuery; using (IDataReader reader = dbCmd.ExecuteReader()) // 테이블에 있는 데이터들이 들어간다. { List <List <TowerStatus> > towerStatusList = new List <List <TowerStatus> >(); for (int n = 0; n < nTypeAmount; ++n) { List <TowerStatus> towerStatus = new List <TowerStatus>(); towerStatusList.Add(towerStatus); } int Count = 0; int Id = 0; while (reader.Read()) { // Debug.Log(reader.GetString(1)); // 타입명 . (몇 열에있는것을 불를것인가) TowerStatus t = new TowerStatus(reader.GetString(0), reader.GetInt32(1), reader.GetInt32(2), reader.GetInt32(3), reader.GetFloat(4), reader.GetFloat(5), reader.GetInt32(6), reader.GetInt32(7), reader.GetFloat(8), reader.GetInt32(9), reader.GetFloat(10), reader.GetFloat(11), reader.GetFloat(12), reader.GetInt32(13), reader.GetFloat(14), reader.GetFloat(15), reader.GetFloat(16), reader.GetFloat(17), reader.GetFloat(18), reader.GetFloat(19), reader.GetFloat(20), reader.GetFloat(21), reader.GetFloat(22), reader.GetFloat(23), reader.GetFloat(24), reader.GetFloat(25), reader.GetFloat(26), reader.GetFloat(27), reader.GetFloat(28), reader.GetFloat(29), reader.GetFloat(30), reader.GetInt32(31), reader.GetFloat(32), reader.GetInt32(33)); if (Count <= nMaxLevelofTower) { towerStatusList[Id].Add(t); Count++; if (Count > nMaxLevelofTower) { //towerStatusList[Id].Add(t); Count = 0; Id++; } } } for (int i = 0; i < nTypeAmount; ++i) { towerStatusDic.Add(towerStatusList[i][0].Name, towerStatusList[i]); } dbConnection.Close(); reader.Close(); } } //foreach (KeyValuePair<string, TowerStatus> TS in towerStatusList) //{ // //print(TS.Key); // //} } } // 타워딕셔너리에 dic[타워이름][타워리스트] 로 넣고 리스트에 인덱스 = 레벨에 동일한 타워 스테이터스가 들어감
public IActionResult Import(IFormFile file, TowerStatus status) { var fname = Guid.NewGuid().ToString().Replace("-", "") + System.IO.Path.GetExtension(file.GetFileName()); var path = System.IO.Path.Combine(System.IO.Path.GetTempPath(), fname); file.SaveAs(path); string connStr; if (System.IO.Path.GetExtension(path) == ".xls") { connStr = "Provider=Microsoft.Jet.OLEDB.4.0;" + "Data Source=" + path + ";" + ";Extended Properties=\"Excel 8.0;HDR=NO;IMEX=1\""; } else { connStr = "Provider=Microsoft.ACE.OLEDB.12.0;" + "Data Source=" + path + ";" + ";Extended Properties=\"Excel 12.0;HDR=NO;IMEX=1\""; } using (var conn = new OleDbConnection(connStr)) { conn.Open(); var schemaTable = conn.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, new object[] { null, null, null, "TABLE" }); var rows = schemaTable.Rows; foreach (System.Data.DataRow r in rows) { if (r["TABLE_NAME"].ToString() == "_xlnm#_FilterDatabase") { continue; } var cmd = new OleDbCommand($"select * from [{r["TABLE_NAME"].ToString()}]", conn); var reader = cmd.ExecuteReader(); var flag = reader.Read(); var cities = User.Claims.Where(x => x.Type == "有权限访问地市数据").Select(x => x.Value).ToList(); if (flag) { while (reader.Read()) { try { if (string.IsNullOrEmpty(reader[0].ToString())) { goto end; } if (User.IsInRole("Member") && !cities.Contains(reader[0].ToString())) { continue; } var tower = new Tower { City = reader[0].ToString(), District = reader[1].ToString(), Provider = (Provider)Enum.Parse(typeof(Provider), reader[2].ToString()), Name = reader[3].ToString(), Scene = (TowerScene)Enum.Parse(typeof(TowerScene), reader[4].ToString()), Lon = Convert.ToDouble(reader[5]), Lat = Convert.ToDouble(reader[6]), Address = reader[7].ToString(), Type = (TowerType)Enum.Parse(typeof(TowerType), reader[8].ToString()), Height = Convert.ToDouble(reader[9]), Time = DateTime.Now }; DB.Towers.Add(tower); } catch (Exception e) { Console.WriteLine(e.ToString()); } } end: DB.SaveChanges(); } } } return(Prompt(x => { x.Title = "导入成功"; x.Details = "铁塔信息已经成功导入数据库!"; })); }
public void Setup(Vector3 position) { this.Position = position; switch (Type) { case TowerType.Plasma: this.Scale = 4.0f; this.BaseType = BaseTowerType.Defense; break; case TowerType.Electric: this.Scale = 3.0f; this.BaseType = BaseTowerType.Defense; break; case TowerType.Cannon: this.Scale = 2.0f; this.BaseType = BaseTowerType.Defense; break; case TowerType.SmallUnit: this.Scale = 2.0f; this.BaseType = BaseTowerType.Offense; break; case TowerType.LargeUnit: this.Scale = 2.0f; this.BaseType = BaseTowerType.Offense; break; } UpdateScaleRotations(); UpdateTransforms(); this.Status = TowerStatus.Active; if (font == null) { font = ScreenManager.Game.Content.Load<SpriteFont>("PlayerMenu\\towerInfoFont"); recycleIcon = ScreenManager.Game.Content.Load<Texture2D>("PlayerMenu\\TowerInfo\\recycle"); repairIcon = ScreenManager.Game.Content.Load<Texture2D>("PlayerMenu\\TowerInfo\\repair"); upgradeIcon = new Texture2D[towerUpgradeEnumType.Length]; for (int i = 0; i < towerUpgradeEnumType.Length; i++) { switch ((TowerUpgradeType)i) { case TowerUpgradeType.Attack: upgradeIcon[i] = ScreenManager.Game.Content.Load<Texture2D>("PlayerMenu\\TowerInfo\\attack"); break; case TowerUpgradeType.Speed: upgradeIcon[i] = ScreenManager.Game.Content.Load<Texture2D>("PlayerMenu\\TowerInfo\\speed"); break; } } unitIconLocation = new Vector2[5][]; highlightUnitIconLocations = new Rectangle[5][]; highlightIcon = ScreenManager.Game.Content.Load<Texture2D>("PlayerMenu\\Icons\\icon_selector"); highlightIconSourceRect = new Rectangle(0, 0, highlightIcon.Width, highlightIcon.Height); highlightOrigin = new Vector2(highlightIcon.Width / 2.0f, highlightIcon.Height / 2.0f); upgradeIconOffset = new Vector2[5]; upgradeStringOffset = new Vector2[5]; repairIconOffset = new Vector2[5]; repairStringOffset = new Vector2[5]; recycleIconOffset = new Vector2[5]; recycleStringOffset = new Vector2[5]; for (int player = 1; player < 4; player++) { unitIconLocation[player] = new Vector2[MAX_UNIT_TYPES]; highlightUnitIconLocations[player] = new Rectangle[MAX_UNIT_TYPES]; Vector2 unitIconStartPosition = new Vector2(180, 60); for (int unit = 0; unit < MAX_UNIT_TYPES; unit++) { unitIconLocation[player][unit] = globalLocations[player] + unitIconStartPosition; highlightUnitIconLocations[player][unit] = new Rectangle((int) (unitIconLocation[player][unit].X - 5.0f + (highlightIcon.Width / 2)), (int)(unitIconLocation[player][unit].Y - 5.0f + (highlightIcon.Height / 2)), highlightIcon.Width, highlightIcon.Height); unitIconStartPosition += unitIconOffset; if (unit == 1) { unitIconStartPosition += unitIconRowOffset; unitIconStartPosition.X = 180; } } upgradeIconOffset[player] = globalLocations[player] + new Vector2(10, 30); upgradeStringOffset[player] = globalLocations[player] + new Vector2(74, 35); repairIconOffset[player] = globalLocations[player] + new Vector2(10, 75); repairStringOffset[player] = globalLocations[player] + new Vector2(74, 80); recycleIconOffset[player] = globalLocations[player] + new Vector2(10, 120); recycleStringOffset[player] = globalLocations[player] + new Vector2(74, 125); } unitInformation = new UnitInformation[MAX_UNIT_TYPES]; unitInformation[0].type = UnitType.SpeedBoat; unitInformation[0].icon = ScreenManager.Game.Content.Load<Texture2D>("PlayerMenu\\Icons\\speedBoat"); unitInformation[2].type = UnitType.SpeederBoat; unitInformation[2].icon = ScreenManager.Game.Content.Load<Texture2D>("PlayerMenu\\Icons\\speederBoat"); killEffect = ScreenManager.Game.Content.Load<SoundEffect>("Sounds\\Effects\\explosion"); } // TowerUpgrades[nextLevel] UpgradeAmounts = new TowerUpgrades[5]; UpgradeAmounts[2].amount = 0.4f; UpgradeAmounts[2].type = TowerUpgradeType.Speed; UpgradeAmounts[2].price = 1000; UpgradeAmounts[2].priceString = UpgradeAmounts[2].price.ToString(); UpgradeAmounts[3].amount = 0.3f; UpgradeAmounts[3].type = TowerUpgradeType.Attack; UpgradeAmounts[3].price = 3000; UpgradeAmounts[3].priceString = UpgradeAmounts[3].price.ToString(); UpgradeAmounts[4].amount = 0.6f; UpgradeAmounts[4].type = TowerUpgradeType.Attack; UpgradeAmounts[4].price = 6000; UpgradeAmounts[4].priceString = UpgradeAmounts[4].price.ToString(); unitTypeSelected = 0; unitSelectionPosition.X = 0; unitSelectionPosition.Y = 0; DestroyCost(); UpgradeCost(); RepairCost(); }
public void OnDied() { Tower t = this; t.towersToAttack.Clear(); this.Status = TowerStatus.Inactive; tile.RemoveBlockableObject(); for (int i = 0; i < tile.tileNeighbors.Count; i++) { tile.tileNeighbors[i].UnregisterTowerListenerForTower(ref t); tile.tileNeighbors[i].UnregisterTowerListenerForUnit(ref t); } }
public void Activate(int playerNum, int teamNum) { Status = TowerStatus.Active; PlayerNum = playerNum; TeamNum = teamNum; switch (Type) { case TowerType.Plasma: HealthCapacity = 500; Cost = 100; attackStrength = 15; timeToAttack = new TimeSpan(0, 0, 0, 0, 500); break; case TowerType.Electric: HealthCapacity = 800; Cost = 200; attackStrength = 60; timeToAttack = new TimeSpan(0, 0, 2); break; case TowerType.Cannon: HealthCapacity = 700; Cost = 170; attackStrength = 35; timeToAttack = new TimeSpan(0, 0, 1); break; case TowerType.SmallUnit: HealthCapacity = 600; Cost = 100; attackStrength = 20; unitBuild = new TimeSpan(0, 0, 3); break; case TowerType.LargeUnit: HealthCapacity = 1000; Cost = 225; attackStrength = 20; unitBuild = new TimeSpan(0, 0, 3); break; } Health = HealthCapacity; XP = 0; Level = 1; TotalInvestedCost = Cost; towersToAttack.Clear(); }
public Tower(TowerType type) { this.rotationMatrixX = Matrix.Identity; this.rotationMatrixY = Matrix.Identity; this.rotationMatrixZ = Matrix.Identity; this.scaleRot = Matrix.Identity; this.scaleMatrix = Matrix.Identity; this.Type = type; this.Status = TowerStatus.Inactive; unitToAttack = null; towersToAttack = new List<Tower>(); // timeToAttack = new TimeSpan(0, 0, 1); currentTimeToAttack = new TimeSpan(); //Depends on Type switch (Type) { case TowerType.Plasma: HealthCapacity = 500; Cost = 100; attackStrength = 15; timeToAttack = new TimeSpan(0,0,0,0, 500); break; case TowerType.Electric: HealthCapacity = 800; Cost = 250; attackStrength = 80; timeToAttack = new TimeSpan(0,0,3); break; case TowerType.Cannon: HealthCapacity = 700; Cost = 170; attackStrength = 30; timeToAttack = new TimeSpan(0,0,1); break; case TowerType.SmallUnit: HealthCapacity = 600; Cost = 200; attackStrength = 20; unitBuild = new TimeSpan(0,0,2); break; case TowerType.LargeUnit: HealthCapacity = 1000; Cost = 450; attackStrength = 20; unitBuild = new TimeSpan(0,0,2); break; } Health = HealthCapacity; XP = 0; Level = 1; TotalInvestedCost = Cost; ID = currentID; currentID++; }
void SetStatus(TowerStatus astatus) { status = astatus; //TODO: visualization }