void Update() { GameObject[] allWalls = GameObject.FindGameObjectsWithTag("Wall"); WallControl[] wallClones = GameObject.FindObjectsOfType <WallControl>(); foreach (WallControl closestWall in wallClones) { Vector3 directionToTarget = closestWall.transform.position - this.transform.position; float dSqrToTarget = directionToTarget.sqrMagnitude; float closestDistanceSqr2 = Mathf.Infinity; WallControl closestTarget2 = null; if (dSqrToTarget < closestDistanceSqr2) { closestDistanceSqr2 = dSqrToTarget; closestTarget2 = closestWall; } Debug.Log(closestWall.transform.position); } //Debug.Log(allWalls.Length); for (int i = 0; i < allWalls.Length; i++) { wallTest.Add(allWalls[i].transform); } for (int i = 0; i < testWall.Length; i++) { GetClosestWall(testWall); // This shows the closest wall Debug.Log("Position is " + GetClosestWall(testWall).position); } }
public virtual Wall this[int row, int column] { get { return(walls[row, column] as Wall); } set { Wall old_wall = walls[row, column] as Wall; if (old_wall == value) { return; } if (value == null) { this.Controls.Remove((old_wall as Control)); walls[row, column] = null; return; } WallControl wall = (value as WallControl); if (wall == null) { throw new Exception("value is not WallControl entity"); } walls[row, column] = wall; wall.Location = getPos(row, column); this.Controls.Remove((old_wall as Control)); this.Controls.Add(wall); wall.to_clear = this; } }
int OnTriggerEnter(Collider other) { if (other.gameObject.CompareTag("Bullet")) { Destroy(other.gameObject); durability -= 1; if (durability <= 0) { Destroy(gameObject); explosion.Play(true); scoreScript.IncreaseScore(points); } } else if (other.gameObject.CompareTag("Wall")) { // Get a reference to a health script attached to the collider we hit WallControl health = other.gameObject.GetComponent <WallControl>(); // If there was a health script attached if (health != null) { // Call the damage function of that script, passing in our enemy damage variable health.Damage(damage); } Destroy(gameObject); } return(durability); }
public WallRotOnClickDecorator1(WallControl wall) : base(wall) { foreach (ControlWithBorder p in wall_parts) { p.MouseClick += changeVertical; } }
private void InitWalls(List <Wall> wallsList) { foreach (Wall w in wallsList) { WallControl wc = new WallControl(_boardControl.Panel); wc.Init(w); _wallsDic.Add(w.Id, wc); } }
public WallDashedBorderDecorator1(WallControl wall) : base(wall) { if (this.wall_parts.Count == 0 || wall_parts[0] == null) { throw new Exception("no ControlWithBorder in wall_parts"); } p1 = wall_parts[0]; DashColor = Color.Yellow; }
public WallSolidBorderDecorator1(WallControl wall) : base(wall) { if (this.wall_parts.Count == 0 || wall_parts[0] == null) { throw new Exception("no ControlWithBorder in wall_parts"); } p1 = wall_parts[0]; BorderColor = Color.Blue; }
public WallDecorator1(WallControl wall) { this.wall_parts = wall.wall_parts; this.wall = wall; wall.Location = new Point(0, 0); this.Controls.Add(wall); resize(); wall.SizeChanged += resize; this.Opacity = 0; }
private WallControl getWallControl(Wall value) { if (value == null) { throw new NullReferenceException("value == null"); } WallControl wall = (value as WallControl); if (wall == null) { throw new Exception("value is not WallControl entity"); } return(wall); }
public Fe11() { Name = "Fe11"; Image = Graphics.resources.Res.Fe11; SetMaxHp(900); SetAttackDamage(30); SetResist(5); SetMovementSpeed(11); SetAttackRange(4); SetAttackSpeed(2); SetMaxEnergy(120); SetEnergyRegen(6); Stacks = 0; WallStacks = 0; Rage = new Perk { Name = "Rage", Explanation = (h) => "AD increased by " + RageADBuff * Stacks + " and armor by " + RageArmorBuff * Stacks + ".", Number = (h) => (h as Fe11).Stacks, GetArmor = (g) => () => g() + Stacks * RageArmorBuff, SetArmor = (s) => (v) => s(v - Stacks * RageArmorBuff), GetAttackDamage = (g) => () => g() + Stacks * RageADBuff, SetAttackDamage = (s) => (v) => s(v - Stacks * RageADBuff), SkillFix = (sf) => { if (sf.SkillTypes.Contains(SkillType.Attack)) { var newSkill = new Skill() { SkillTypes = sf.SkillTypes, Job = (h) => { var prev = sf.Job(h); if (prev) { (h as Fe11).Stacks++; } return(prev); } }; return(newSkill); } return(sf); }, //Stuff from Wall skill EndTurn = (i) => (d) => { var h = (d.HeroValue as Fe11); var a = i(d); if (h.WallOn) { var wallCost = (WallBaseManaPerTurnCost * Math.Pow(WallTurnManaMultiplier, h.WallStacks)); if (h.GetEnergy() < wallCost) { WallControl.Disactivate(h); h.M.Effects.Remove(WallControl); h.WallStacks--; } else { h.AddEnergy(-wallCost); h.WallStacks++; } } else { if (h.WallStacks > 0) { h.WallStacks--; } } return(a); }, }; Perks.Add(Rage); Skills.Remove(Attack); BuffedAttack = new Skill { Name = Attack.Name, Explanation = () => Attack.Explanation() + "On attack increases you AD by " + RageADBuff + " and armor by " + RageArmorBuff + ".", Job = Attack.Job }; BuffedAttack.SkillTypes.Add(SkillType.Attack); Skills.Add(BuffedAttack); WallControl = new Effect(this, int.MaxValue) { Activate = (h) => { (h as Fe11).BuildWall(h); }, Disactivate = (h) => { (h as Fe11).DestroyWall(h.M); }, }; Wall = new Skill { Name = "YouShallNotPass", Explanation = () => WallOn ? "Destroyes the wall builded by this skill. (current cost " + WallBaseManaPerTurnCost * Math.Pow(WallTurnManaMultiplier, WallStacks) + ")" : "Builds a wall in " + WallMinDist + "-" + WallMaxDist + " range around you. On next use destroyes it. At the end of turn eats " + WallBaseManaPerTurnCost * Math.Pow(WallTurnManaMultiplier, WallStacks) + " energy and increase its next cost by " + WallTurnManaMultiplier * 100 + "% (when disactivated - decrease). energy at the end of turn (if not enough - turnes off).", Job = (h) => { if (WallOn) { WallControl.Disactivate(h); h.M.Effects.Remove(WallControl); } else { h.M.Effects.Add(WallControl); WallControl.Activate(h); } return(WallOn); }, }; Wall.SkillTypes.Add(SkillType.Special); Skills.Add(Wall); }