void Start() { coolDown_Load = 0; coolDown = 1;// _Stats.Attributes.Find(x => x.Name == scr_Attributes.Attribute.coolDown); dmg = _Stats.Attributes.Find(x => x.Name == scr_Attributes.Attribute.Damage); range = _Stats.Attributes.Find(x => x.Name == scr_Attributes.Attribute.Range); }
private void Start() { healthMax = _Stats.Attributes.Find(x => x.Name == scr_Attributes.Attribute.Maximum_Health); health = GetComponent <scr_DataSet>().Attributes.Find(x => x.Name == scr_Attributes.Attribute.Health); createsEnergy = _Stats.Attributes.Find(x => x.Name == scr_Attributes.Attribute.Creates_energy); health.Value = healthMax.Value; timeLeft = 1; }
void Start() { statsScr = GetComponent <scr_DataSet>(); health = statsScr.Attributes.Find(x => x.Name == scr_Attributes.Attribute.Health); healthMax = _Stats.Attributes.Find(x => x.Name == scr_Attributes.Attribute.Maximum_Health); moveSpeed = _Stats.Attributes.Find(x => x.Name == scr_Attributes.Attribute.Movement_Speed); rotationSpeed = _Stats.Attributes.Find(x => x.Name == scr_Attributes.Attribute.Rotation_speed); health.Value = healthMax.Value; }
void Awake() { scr_Attributes.Attribute ressourcePerScondEnum = scr_Attributes.Attribute.Coal_per_second; Renderer materialRenderer = _MaterialParticleSystem.GetComponent <Renderer>(); switch (resourceToTake) { case scr_Attributes.Attribute.Coal: ressourcePerScondEnum = scr_Attributes.Attribute.Coal_per_second; materialRenderer.material = _ColeMaterial; break; case scr_Attributes.Attribute.Dida: ressourcePerScondEnum = scr_Attributes.Attribute.Dida_per_second; materialRenderer.material = _DidaMaterial; break; case scr_Attributes.Attribute.Gale: ressourcePerScondEnum = scr_Attributes.Attribute.Gale_per_second; materialRenderer.material = _GaleMaterial; break; case scr_Attributes.Attribute.Iron: ressourcePerScondEnum = scr_Attributes.Attribute.Iron_per_second; materialRenderer.material = _IronMaterial; break; case scr_Attributes.Attribute.Stone: ressourcePerScondEnum = scr_Attributes.Attribute.Stone_per_second; materialRenderer.material = _StoneMaterial; break; } ressourcePerSecond = _Stats.Attributes.Find(x => x.Name == ressourcePerScondEnum); healthMax = _Stats.Attributes.Find(x => x.Name == scr_Attributes.Attribute.Maximum_Health); health = GetComponent <scr_DataSet>().Attributes.Find(x => x.Name == scr_Attributes.Attribute.Health); energyCost = _Stats.Attributes.Find(x => x.Name == scr_Attributes.Attribute.Cost_Energy); health.Value = healthMax.Value; timeLeft = 1; animator = GetComponent <Animator>(); _StatsGlobal.Energy -= (int)energyCost.Value; }
void Start() { health = GetComponent <scr_DataSet>().Attributes.Find(x => x.Name == scr_Attributes.Attribute.Health); healthMax = _Stats.Attributes.Find(x => x.Name == scr_Attributes.Attribute.Maximum_Health); energyCost = _Stats.Attributes.Find(x => x.Name == scr_Attributes.Attribute.Cost_Energy); minimumRange = _Stats.Attributes.Find(x => x.Name == scr_Attributes.Attribute.Minimum_range); range = _Stats.Attributes.Find(x => x.Name == scr_Attributes.Attribute.Range); damage = _Stats.Attributes.Find(x => x.Name == scr_Attributes.Attribute.Damage); fireRate = _Stats.Attributes.Find(x => x.Name == scr_Attributes.Attribute.Fire_rate); rotationSpeed = _Stats.Attributes.Find(x => x.Name == scr_Attributes.Attribute.Rotation_speed); health.Value = healthMax.Value; timeLeftToFire += fireRate.Value; _StatsGlobal.Energy -= (int)energyCost.Value; headDefault = _Head.transform.rotation.Copy(); cannonRotateTowards = new GameObject("_CannonRotateTowards"); cannonRotateTowards.transform.rotation = this.transform.rotation; cannonRotateTowards.transform.SetParent(_Head.transform); }
private void Start() { scrStats = GetComponent <scr_DataSet>(); health = scrStats.Attributes.Find(x => x.Name == scr_Attributes.Attribute.Health); healthMax = _Stats.Attributes.Find(x => x.Name == scr_Attributes.Attribute.Maximum_Health); visibilityRange = _Stats.Attributes.Find(x => x.Name == scr_Attributes.Attribute.Visibility_Range); rotationSpeed = _Stats.Attributes.Find(x => x.Name == scr_Attributes.Attribute.Rotation_speed); movementSpeed = _Stats.Attributes.Find(x => x.Name == scr_Attributes.Attribute.Movement_Speed); fireRate = _Stats.Attributes.Find(x => x.Name == scr_Attributes.Attribute.Fire_rate); damage = _Stats.Attributes.Find(x => x.Name == scr_Attributes.Attribute.Damage); attackRange = _Stats.Attributes.Find(x => x.Name == scr_Attributes.Attribute.Range); health.Value = healthMax.Value; player = GameObject.FindGameObjectWithTag(scr_Tags.Player); path = new List <Vector3>(); myRigidbody = GetComponent <Rigidbody>(); if (player == null) { throw new Exception("No player found!"); } }
void Attack(GameObject go) { timeToAttack -= Time.deltaTime; if (timeToAttack <= 0) { I_IDamagable dmgable = go.GetComponent <I_IDamagable>(); so_DataSet.Attribute healthSo = dmgable.GetSoDataSet().Attributes.Where(x => x.Name == scr_Attributes.Attribute.Health).First(); if (healthSo.TakeFromLocalDataSet) { scr_DataSet.Attribute healthScr = dmgable.GetScrDataSet().Attributes.Where(x => x.Name == scr_Attributes.Attribute.Health).First(); healthScr.Value -= damage.Value; } else { healthSo.Value -= damage.Value; } timeToAttack = fireRate.Value; } }
void Update() { if (health.Value <= 0) { Destroy(this.gameObject); return; } if (_StatsGlobal.Energy < 0) { return; } if (timeLeftToFire > 0) { timeLeftToFire -= Time.deltaTime; } GameObject enemy = GetEnemy(); if (enemy != null) { RotateHeadTowards(enemy.transform.position); RotateCannoneTowards(enemy.transform.position); if (timeLeftToFire <= 0 && IsLookingAtEnemy(enemy)) { I_IDamagable damagable = enemy.GetComponent <I_IDamagable>(); if (damagable == null) { throw new Exception("GameObject with tag " + scr_Tags.Enemy + " need I_IDamagable script!"); } so_DataSet.Attribute soHealth = damagable.GetSoDataSet().Attributes.Where(x => x.Name == scr_Attributes.Attribute.Health).FirstOrDefault(); if (soHealth == null) { throw new Exception("I_IDamagable needs health attribute!"); } if (soHealth.TakeFromLocalDataSet) { scr_DataSet.Attribute scrHealth = damagable.GetScrDataSet().Attributes.Where(x => x.Name == scr_Attributes.Attribute.Health).FirstOrDefault(); if (scrHealth == null) { throw new Exception("I_IDamagable needs health attribute!"); } scrHealth.Value -= damage.Value; } else { soHealth.Value -= damage.Value; } GameObject go = Instantiate(_LaserPrefab); go.transform.position = _FirePosition.transform.position; go.transform.LookAt(enemy.transform.position); float distance = Vector3.Distance(_FirePosition.transform.position, enemy.transform.position); go.GetComponent <I_ILaser>().SetLength(distance); shotSource.Play(); timeLeftToFire = fireRate.Value; } } else { RotateToDefault(); } }
void ShootWeapon() { RaycastHit hit; Ray ray = new Ray(bullet_Spawn.position - (bullet_Spawn.right / 2), bullet_Spawn.right); Debug.DrawRay(ray.origin, ray.direction, Color.blue); if (Physics.Raycast(ray, out hit, range.Value)) { Transform objectHit = hit.transform; bool damageDeal = false; if (objectHit) { scr_DecoOnDamage decoScript = objectHit.GetComponent <scr_DecoOnDamage>(); if (decoScript) { decoScript.MarkDamaged(); } I_IDamagable targetDamagable = objectHit.GetComponent <I_IDamagable>(); if (targetDamagable != null) { so_DataSet.Attribute sotargetHealth = targetDamagable.GetSoDataSet().Attributes.Find(x => x.Name == scr_Attributes.Attribute.Health); if (sotargetHealth.TakeFromLocalDataSet) { scr_DataSet.Attribute targetHealth = targetDamagable.GetScrDataSet().Attributes.Find(x => x.Name == scr_Attributes.Attribute.Health); if (targetHealth != null) { targetHealth.Value -= dmg.Value; damageDeal = true; } } if (damageDeal) { so_DataSet.Attribute typeOfOreBonus = targetDamagable.GetSoDataSet().Attributes.Find(x => x.Name == scr_Attributes.Attribute.Gale); if (typeOfOreBonus != null) { _StatsGlobal.CrystalGale += (int)typeOfOreBonus.Value; } if (typeOfOreBonus == null) { typeOfOreBonus = targetDamagable.GetSoDataSet().Attributes.Find(x => x.Name == scr_Attributes.Attribute.Dida); if (typeOfOreBonus != null) { _StatsGlobal.CrystalDida += (int)typeOfOreBonus.Value; } } if (typeOfOreBonus == null) { typeOfOreBonus = targetDamagable.GetSoDataSet().Attributes.Find(x => x.Name == scr_Attributes.Attribute.Iron); if (typeOfOreBonus != null) { _StatsGlobal.Iron += (int)typeOfOreBonus.Value; } } if (typeOfOreBonus == null) { typeOfOreBonus = targetDamagable.GetSoDataSet().Attributes.Find(x => x.Name == scr_Attributes.Attribute.Stone); if (typeOfOreBonus != null) { _StatsGlobal.Stone += (int)typeOfOreBonus.Value; } } if (typeOfOreBonus == null) { typeOfOreBonus = targetDamagable.GetSoDataSet().Attributes.Find(x => x.Name == scr_Attributes.Attribute.Coal); if (typeOfOreBonus != null) { _StatsGlobal.Coal += (int)typeOfOreBonus.Value; } } } //else //nothing! //{ // sotargetHealth.Value -= dmg; //} } } } }
// Use this for initialization void Start() { AttributeHealth = DataSet.Attributes.Where(x => x.Name == scr_Attributes.Attribute.Health).First(); }
void Start() { movePower = _Stats.Attributes.Find(x => x.Name == scr_Attributes.Attribute.Movement_Speed); rotarePower = _Stats.Attributes.Find(x => x.Name == scr_Attributes.Attribute.Rotation_speed); Rigid = GetComponent <Rigidbody>(); }
void Start() { healthMax = _Stats.Attributes.Find(x => x.Name == scr_Attributes.Attribute.Maximum_Health); health = GetComponent <scr_DataSet>().Attributes.Find(x => x.Name == scr_Attributes.Attribute.Health); health.Value = healthMax.Value; }