// Use this for initialization void Start() { //efectoRayo = Instantiate(Resources.Load("Spark"), this.transform.position, Quaternion.identity) as GameObject; //efectoRayo.transform.parent = this.transform; gameManager = GameObject.FindGameObjectWithTag("GameController").GetComponent <GameManager>(); totem = GetComponentInParent <Totem>(); activarEfecto(); }
void Start() { this.WeaponLogic = GetComponent <WeaponLogic>(); this.mov = GetComponent <MovimientoController>(); this.totemController = GetComponent <Totem>(); initLine(); this.stateHolder = GameObject.FindGameObjectWithTag("GameController").GetComponent <StateHolder>(); }
// Use this for initialization void Start() { gameManager = GameObject.FindGameObjectWithTag("GameController").GetComponent <GameManager>(); rondaInicial = gameManager.GetRondaActual(); numeroUsos = 0; totem = GetComponentInParent <Totem>(); posicionValidaTotem = totem.transform.position; }
// Use this for initialization void Start() { gameManager = GameObject.FindGameObjectWithTag("GameController").GetComponent <GameManager>(); rondaInicial = gameManager.GetRondaActual(); numeroUsos = 0; totem = GetComponentInParent <Totem>(); capaBala = totem.gameObject.layer == Global.Capas.totemsPrimerJugador ? Global.Capas.balaPrimerJugador : Global.Capas.balaSegundoJugador; }
// Use this for initialization void Start() { totemObject = transform.parent.gameObject.transform.parent.gameObject; totem = totemObject.GetComponent <Totem> (); maxHealth = totem.getMaxHealth(); currentHealth = totem.getCurrentHealth(); currentHealthBar = transform.GetChild(0).gameObject; }
private void CreateTotems() { for (int i = 0; i < cols; i++) { Transform newTotemTF = Instantiate(totem, new Vector3(i * totemSpacing, 0, 0), Quaternion.LookRotation(Vector3.back)) as Transform; Totem newTotem = newTotemTF.gameObject.GetComponent <Totem> (); newTotem.Init(this, rows, i); } }
// Use this for initialization void Start() { GameObject efectoBola = Instantiate(Resources.Load("ErekiBall2"), this.transform.position, Quaternion.identity) as GameObject; efectoBola.transform.parent = this.transform; gameManager = GameObject.FindGameObjectWithTag("GameController").GetComponent <GameManager>(); totem = GetComponentInParent <Totem>(); transportado = false; }
public void addTotemItems(Totem totemActual) { List <int> totemItems = totemActual.getItemList(); foreach (int item in totemItems) { this.hotbar.addItemToInventory(item); } }
public RegenTimer(Mobile caster, Totem totem, TimeSpan duration, TimeSpan intervale) : base(TimeSpan.FromSeconds(1.0), intervale) { m_Caster = caster; m_Totem = totem; totem.timer = this; m_End = DateTime.Now + duration; Priority = TimerPriority.FiftyMS; }
private void SetAirTotemPictures(Totem totem) { pictureBoxAirTotem.Image = totem?.Icon; myToolTip.SetToolTip(pictureBoxAirTotem, "mod"); pictureBoxAirTotem.Tag = totem?.Tooltip; if (totem?.Tooltip == null) { myToolTip.SetToolTip(pictureBoxAirTotem, ""); } }
public void SetHUD(Totem totem) { Debug.Log("HUD" + totem + " Active"); HUD.gameObject.SetActive(true); totemName.text = totem.totemName; SetHP(totem.totemCurrentHP); DmgText.text = totem.totemDamage.ToString(); DefText.text = totem.totemCurrentDefence.ToString(); ActionHUDReset(totem); switch (totem.TotemElementType) { case Element.Fire: EarthPanel.active = false; FirePanel.active = true; WaterPanel.active = false; AirPanel.active = false; TotemPanel.active = false; break; case Element.Water: EarthPanel.active = false; FirePanel.active = false; WaterPanel.active = true; AirPanel.active = false; TotemPanel.active = false; break; case Element.Earth: EarthPanel.active = true; FirePanel.active = false; WaterPanel.active = false; AirPanel.active = false; TotemPanel.active = false; break; case Element.Air: EarthPanel.active = false; FirePanel.active = false; WaterPanel.active = false; AirPanel.active = true; TotemPanel.active = false; break; default: EarthPanel.active = false; FirePanel.active = false; WaterPanel.active = false; AirPanel.active = false; TotemPanel.active = true; break; } }
public Player(string playerName, Totem totem, bool isHuman, int index) { PlayerName = playerName; Totem = totem; IsHuman = isHuman; Index = index; Cash = 1500; Location = Locations.Go; Holdings = new List<Property>(); }
public static bool CallTotem(Totem totem) { var spell = WoWSpell.GetSpell((int)totem); if (spell.IsValid && spell.IsReady) { Log.WriteLine("Calling {0} totem", totem.ToString()); spell.Cast(); return true; } return false; }
public void HasTotemAttacked(Totem totemA) { if (totemA.hasAttack == false) { totemA.hasAttack = true; } else { return; } }
public static bool CallTotem(Totem totem) { var spell = WoWSpell.GetSpell((int)totem); if (spell.IsValid && spell.IsReady) { Log.WriteLine("Calling {0} totem", totem.ToString()); spell.Cast(); return(true); } return(false); }
public static bool CallTotem(Totem totem) { WoWSpell spell = Manager.Spellbook[((uint)totem)]; if (spell.IsValid && spell.IsReady) { Log.WriteLine("Calling {0} totem", totem.ToString()); spell.Cast(); return(true); } return(false); }
public void ClearOtherSelection() { Totems = GameObject.FindGameObjectsWithTag("Totem"); foreach (GameObject Totem in Totems) { if (Totem != ActiveTotem || EnemyTotem) { Totem.GetComponentInChildren <Renderer>().material = Totem.GetComponentInChildren <Totem>().TotemMat; } } }
public void Run() { foreach (var pos in TotemPositionList) { Totem totem = new Totem(pos); Bloodbender.ptr.listGraphicObj.Add(totem); Texture2D tex = Bloodbender.ptr.Content.Load<Texture2D>("Totem"); totem.addAnimation(new Animation(tex)); } _isOn = true; }
public static double GetTotemBonus(Mobile m, TotemType totemtype) { if (m == null) { return(0); } ArrayList targets = new ArrayList(); Map map = m.Map; if (map != null) { foreach (Item item in m.GetItemsInRange(15)) { if (item != null && m.CanSee(item) && item is Totem) { targets.Add(item); } } } Totem chosen = null; for (int i = 0; i < targets.Count; ++i) { Totem totem = (Totem)targets[i]; if (totem != null && totem.TotemType == totemtype) { if (m.InRange(totem, totem.MaxRange)) { if (chosen == null || chosen.Bonus < totem.Bonus) { chosen = totem; } } } } if (chosen != null && m != null && chosen.TotemType != TotemType.Amulette && chosen.TotemType != TotemType.Miracle && chosen.TotemType != TotemType.Refecteur) { Effects.SendTargetParticles(m, chosen.EffectID, chosen.EffectSpeed, chosen.EffectDuration, 5005, chosen.Hue, 0, chosen.EffectLayer); } if (chosen == null) { return(0); } return(chosen.Bonus); }
public void TotemDefend(Totem totemA) { if (totemA.isDefending == false) { totemA.totemCurrentDefence += totemA.totemDefence; totemA.isDefending = true; FindObjectOfType <SoundManager>().Play("TotemDefAudio"); } else if (totemA.isDefending == true) { return; } }
public void Init(GridSpace ggparent, Totem gparent, int symbolID, int rows, int tileIndex, float _tileHeight) { // Initialize members from parent gparent_totem = gparent; ggparent_gridSpace = ggparent; id = symbolID; index = tileIndex; tileNum = index % rows; perRow = (rows + 1) / 2; tileHeight = _tileHeight; rend = GetComponent <Renderer> (); }
public static void retargetTotem() { List <WoWUnit> mobList = ObjectManager.GetObjectsOfType <WoWUnit>(false); foreach (WoWUnit Totem in mobList) { if (Totem.CreatureType == WoWCreatureType.Totem && Totem.CurrentHealth > 1 && Totem.Attackable) { Log("Totem on the Feild Targeting Totem!"); Totem.Target(); } } }
void OnCollisionEnter2D(Collision2D collision) { if (collision.transform.gameObject == this.Player) { Physics2D.IgnoreCollision(GetComponent <BoxCollider2D>(), collision.collider); } string tag = collision.collider.tag; if (tag == "TerrainObject") { Physics2D.IgnoreCollision(GetComponent <BoxCollider2D>(), collision.collider); Terrain2 t = collision.gameObject.GetComponent <Terrain2>(); float tmp = destructionCircle.radius; destructionCircle.radius = radius; t.DestroyGround(destructionCircle); destructionCircle.radius = tmp; } else if (tag.Contains("Player")) { int id = collision.collider.gameObject.GetInstanceID(); GameObject[] totems = GameObject.FindGameObjectsWithTag(tag.Replace("Module", "")); foreach (GameObject g in totems) { Totem totem = g.GetComponent <Totem>(); foreach (GameObject mod in totem.Modulos) { if (mod.GetInstanceID() == id) { if (totem.IgluActivado() && (mod.GetInstanceID() == totem.GetIDModuloProtegidoIglu())) { Iglu ig = totem.GetComponentInChildren <Iglu>(); ig.IncNumeroUsos(); Destroy(this.gameObject); } else { totem.SendMessage("Damage", new HealthEvent(gameObject, damage)); totem.DecreaseVida(); } } } } } GameObject executeDeathExplosion = Instantiate(this.explosion, this.gameObject.transform.position, this.explosion.transform.rotation); Destroy(executeDeathExplosion, executeDeathExplosion.GetComponent <AudioSource>().clip.length); Destroy(this.gameObject); }
public void RemoveTotem(Totem totem) { if (totem.tag == Global.TOTEM_FIRST_PLAYER) { listaTotemsJugador.Remove(totem); listaNombreTotemsJugador [totem.name] = 0; } else { listaTotemsContrincante.Remove(totem); listaNombreTotemsContrincante [totem.name] = 0; } Destroy(totem.gameObject); }
public void guardarItem(Totem totem, int itemID) { if (totem.tag == totemActual.tag) { this.inventario.addItemToInventory(itemID); } if (totem.tag == Global.TOTEM_FIRST_PLAYER) { this.listaItemsPrimerJugador.Add(itemID); } else { this.listaItemsSegundoJugador.Add(itemID); } }
private static DateTime?GetEarliestReuseDate(Totem totem) { var entriesWithoutKnownReuseDate = totem.TotemEntries.Any(x => x.ReuseDateTotem.Year == 1); if (entriesWithoutKnownReuseDate) { return(null); } if (!totem.TotemEntries.Any()) { return(DateTime.MinValue); } return(totem.TotemEntries?.Max(x => x.ReuseDateTotem)); }
public void ClearSelection() { Totems = GameObject.FindGameObjectsWithTag("Totem"); foreach (GameObject Totem in Totems) { Totem.GetComponentInChildren <Renderer>().material = Totem.GetComponentInChildren <Totem>().TotemMat; } EnebattleHUD.ResetHUD(EnemyTotem); CurrbattleHUD.ResetHUD(ActiveTotem); EnemyTotem = null; ActiveTotem = null; Selectedtotem = null; ClearOtherSelection(); }
public static GridCell RegisterTotem(int playerId, Totem totem) { var x = (int)Math.Floor(totem.transform.position.x); var z = (int)Math.Floor(totem.transform.position.z); var gridCell = Instance.Cells[x, z]; if (gridCell.Occupant != null) { return(null); } gridCell.Occupant = totem.gameObject; Instance.Totems[playerId].Add(totem); return(gridCell); }
public void OnTrigger(Collider2D other) { Character character = other.GetComponent <Character>(); if (character != null) { if (character != m_sword.character) { m_sword.particleHit.Play(true); ProCamera2DShake.Instance.Shake(ProCamera2DShake.Instance.ShakePresets[3]); character.lifeManager.RemoveLife(1); } } Pillar pillar = other.GetComponent <Pillar>(); if (pillar != null) { pillar.sword = m_sword; m_sword.pillar = pillar; m_sword.particleHit.Play(true); ProCamera2DShake.Instance.Shake(ProCamera2DShake.Instance.ShakePresets[1]); m_sword.SetState(new SIdle()); m_sword.transform.SetParent(pillar.transform); if (m_sword.character != null) { Joystick.Instance.Vibrate(0.5f, m_sword.character.joystickId); } VictoryManager.Instance.InvokeStop(); return; } Totem totem = other.GetComponent <Totem>(); if (totem != null) { if (totem != m_sword.character.totem) { totem.sword = m_sword; m_sword.particleHit.Play(true); totem.lifeManager.RemoveLife(1); m_sword.transform.SetParent(totem.transform); } m_sword.SetState(new SIdle()); } }
void OnCollisionEnter2D(Collision2D collision) { if (collision.transform.gameObject == this.Player) { Physics2D.IgnoreCollision(GetComponent <BoxCollider2D>(), collision.collider); } string tag = collision.collider.tag; if (tag == "TerrainObject") { if (!ignore) { Invoke("Explosion", 2); } ignore = true; } else if (tag.Contains("Player")) { int id = collision.collider.gameObject.GetInstanceID(); GameObject[] totems = GameObject.FindGameObjectsWithTag(tag.Replace("Module", "")); foreach (GameObject g in totems) { Totem totem = g.GetComponent <Totem>(); foreach (GameObject mod in totem.Modulos) { if (mod.GetInstanceID() == id) { if (totem.IgluActivado() && (mod.GetInstanceID() == totem.GetIDModuloProtegidoIglu())) { Iglu ig = totem.GetComponentInChildren <Iglu>(); ig.IncNumeroUsos(); Destroy(this.gameObject); } else { totem.SendMessage("Damage", new HealthEvent(gameObject, damage)); totem.DecreaseVida(); } } } } } this.collision = collision; }
void SpawnTotem(Vector3 postion) { // selectedTotem.isTotemOcc = true; switch (totemElementType) { case Element.Fire: selectedTotem = FireTotem; selectedTotem.totemIs = TotemIs; selectedTotem.SetMat(); selectedTotem.TotemTileNumber = TileNumber; selectedTotem = Instantiate(selectedTotem, postion, Quaternion.identity); break; case Element.Water: selectedTotem = WaterTotem; selectedTotem.totemIs = TotemIs; selectedTotem.SetMat(); selectedTotem.TotemTileNumber = TileNumber; selectedTotem = Instantiate(selectedTotem, postion, Quaternion.identity); break; case Element.Earth: selectedTotem = EarthTotem; selectedTotem.totemIs = TotemIs; selectedTotem.SetMat(); selectedTotem.TotemTileNumber = TileNumber; selectedTotem = Instantiate(selectedTotem, postion, Quaternion.identity); break; case Element.Air: selectedTotem = AirTotem; selectedTotem.totemIs = TotemIs; selectedTotem.SetMat(); selectedTotem.TotemTileNumber = TileNumber; selectedTotem = Instantiate(selectedTotem, postion, Quaternion.identity); break; default: break; } isTotemPlaced = true; }
// Update is called once per frame void Update() { healthBar.value = GameManager.currentLife; if (totem != null) { repairProgress.value = totem.totemPercent; repairProgress.gameObject.SetActive(true); if (totem.totemPercent == 100) { totem = null; } } else { repairProgress.gameObject.SetActive(false); } }
private void Activate(RealmTime time, Item item, Position target) { MP -= item.MpCost; foreach (var eff in item.ActivateEffects) { switch (eff.Effect) { case ActivateEffects.BulletNova: { var prjDesc = item.Projectiles[0]; //Assume only one var batch = new Packet[21]; var s = Random.CurrentSeed; Random.CurrentSeed = (uint)(s * time.tickTimes); for (var i = 0; i < 20; i++) { var random = new Random(); var SpellTarget = new Position { X = (float)(random.NextDouble() * (target.X + 2 - (target.X - 2)) + (target.X - 2)), Y = (float)(random.NextDouble() * (target.Y + 2 - (target.Y - 2)) + (target.Y - 2)) }; var proj = CreateProjectile(prjDesc, item.ObjectType, (int)statsMgr.GetAttackDamage(prjDesc.MinDamage, prjDesc.MaxDamage), time.tickTimes, SpellTarget, (float)(i * (Math.PI * 2) / 20)); Owner.EnterWorld(proj); FameCounter.Shoot(proj); batch[i] = new ShootPacket { BulletId = proj.ProjectileId, OwnerId = Id, ContainerType = item.ObjectType, Position = target, Angle = proj.Angle, Damage = (short)proj.Damage }; } Random.CurrentSeed = s; batch[20] = new ShowEffectPacket { EffectType = EffectType.Trail, PosA = target, TargetId = Id, Color = new ARGB(0xFFFF00AA) }; Owner.BroadcastPackets(batch, null); } break; case ActivateEffects.Shoot: { ActivateShoot(time, item, target); } break; case ActivateEffects.DualShoot: { ActivateDualShoot(time, item, target); } break; case ActivateEffects.StatBoostSelf: { var idx = -1; switch ((StatsType)eff.Stats) { case StatsType.MaximumHP: idx = 0; break; case StatsType.MaximumMP: idx = 1; break; case StatsType.Attack: idx = 2; break; case StatsType.Defense: idx = 3; break; case StatsType.Speed: idx = 4; break; case StatsType.Vitality: idx = 5; break; case StatsType.Wisdom: idx = 6; break; case StatsType.Dexterity: idx = 7; break; } var pkts = new List<Packet>(); ActivateBoostStat(this, idx, pkts); var OGstat = oldstat; var s = eff.Amount; Boost[idx] += s; UpdateCount++; Owner.Timers.Add(new WorldTimer(eff.DurationMS, (world, t) => { Boost[idx] = OGstat; UpdateCount++; })); Owner.BroadcastPacket(new ShowEffectPacket { EffectType = EffectType.Potion, TargetId = Id, Color = new ARGB(0xffffffff) }, null); } break; case ActivateEffects.StatBoostAura: { var idx = -1; switch ((StatsType)eff.Stats) { case StatsType.MaximumHP: idx = 0; break; case StatsType.MaximumMP: idx = 1; break; case StatsType.Attack: idx = 2; break; case StatsType.Defense: idx = 3; break; case StatsType.Speed: idx = 4; break; case StatsType.Vitality: idx = 5; break; case StatsType.Wisdom: idx = 6; break; case StatsType.Dexterity: idx = 7; break; } var s = eff.Amount; BehaviorBase.AOE(Owner, this, eff.Range, true, player => { (player as Player).Boost[idx] += s; player.UpdateCount++; Owner.Timers.Add(new WorldTimer(eff.DurationMS, (world, t) => { (player as Player).Boost[idx] -= s; player.UpdateCount++; })); }); Owner.BroadcastPacket(new ShowEffectPacket { EffectType = EffectType.AreaBlast, TargetId = Id, Color = new ARGB(0xffffffff), PosA = new Position { X = eff.Range } }, null); } break; case ActivateEffects.ConditionEffectSelf: { ApplyConditionEffect(new ConditionEffect { Effect = eff.ConditionEffect.Value, DurationMS = eff.DurationMS }); Owner.BroadcastPacket(new ShowEffectPacket { EffectType = EffectType.AreaBlast, TargetId = Id, Color = new ARGB(0xffffffff), PosA = new Position { X = 1 } }, null); } break; case ActivateEffects.ConditionEffectAura: { BehaviorBase.AOE(Owner, this, eff.Range, true, player => { player.ApplyConditionEffect(new ConditionEffect { Effect = eff.ConditionEffect.Value, DurationMS = eff.DurationMS }); }); var color = 0xffffffff; if (eff.ConditionEffect.Value == ConditionEffectIndex.Damaging) color = 0xffff0000; Owner.BroadcastPacket(new ShowEffectPacket { EffectType = EffectType.AreaBlast, TargetId = Id, Color = new ARGB(color), PosA = new Position { X = eff.Range } }, null); } break; case ActivateEffects.Heal: { var pkts = new List<Packet>(); ActivateHealHp(this, eff.Amount, pkts); Owner.BroadcastPackets(pkts, null); } break; case ActivateEffects.HealNova: { var pkts = new List<Packet>(); BehaviorBase.AOE(Owner, this, eff.Range, true, player => { ActivateHealHp(player as Player, eff.Amount, pkts); }); pkts.Add(new ShowEffectPacket { EffectType = EffectType.AreaBlast, TargetId = Id, Color = new ARGB(0xffffffff), PosA = new Position { X = eff.Range } }); Owner.BroadcastPackets(pkts, null); } break; case ActivateEffects.Magic: { var pkts = new List<Packet>(); ActivateHealMp(this, eff.Amount, pkts); Owner.BroadcastPackets(pkts, null); } break; case ActivateEffects.MagicNova: { var pkts = new List<Packet>(); BehaviorBase.AOE(Owner, this, eff.Range, true, player => { ActivateHealMp(player as Player, eff.Amount, pkts); }); pkts.Add(new ShowEffectPacket { EffectType = EffectType.AreaBlast, TargetId = Id, Color = new ARGB(0xffffffff), PosA = new Position { X = eff.Range } }); Owner.BroadcastPackets(pkts, null); } break; case ActivateEffects.Teleport: { Move(target.X, target.Y); UpdateCount++; Owner.BroadcastPackets(new Packet[] { new GotoPacket { ObjectId = Id, Position = new Position { X = X, Y = Y } }, new ShowEffectPacket { EffectType = EffectType.Teleport, TargetId = Id, PosA = new Position { X = X, Y = Y }, Color = new ARGB(0xFFFFFFFF) } }, null); } break; case ActivateEffects.VampireBlast: { var pkts = new List<Packet>(); pkts.Add(new ShowEffectPacket { EffectType = EffectType.Trail, TargetId = Id, PosA = target, Color = new ARGB(0xFFFF0000) }); pkts.Add(new ShowEffectPacket { EffectType = EffectType.Diffuse, Color = new ARGB(0xFFFF0000), TargetId = Id, PosA = target, PosB = new Position { X = target.X + eff.Radius, Y = target.Y } }); var totalDmg = 0; var enemies = new List<Enemy>(); BehaviorBase.AOE(Owner, target, eff.Radius, false, enemy => { enemies.Add(enemy as Enemy); totalDmg += (enemy as Enemy).Damage(this, time, eff.TotalDamage, false); }); var players = new List<Player>(); BehaviorBase.AOE(Owner, this, eff.Radius, true, player => { players.Add(player as Player); ActivateHealHp(player as Player, totalDmg, pkts); }); var rand = new Random(); for (var i = 0; i < 5; i++) { var a = enemies[rand.Next(0, enemies.Count)]; var b = players[rand.Next(0, players.Count)]; pkts.Add(new ShowEffectPacket { EffectType = EffectType.Flow, TargetId = b.Id, PosA = new Position { X = a.X, Y = a.Y }, Color = new ARGB(0xffffffff) }); } if (enemies.Count > 0) { var a = enemies[rand.Next(0, enemies.Count)]; var b = players[rand.Next(0, players.Count)]; pkts.Add(new ShowEffectPacket { EffectType = EffectType.Flow, TargetId = b.Id, PosA = new Position { X = a.X, Y = a.Y }, Color = new ARGB(0Xffffffff) }); } Owner.BroadcastPackets(pkts, null); } break; case ActivateEffects.Trap: { var effColor = new ARGB(0xff9000ff); if (eff.Color != null) effColor = new ARGB((uint)eff.Color); Owner.BroadcastPacket(new ShowEffectPacket { EffectType = EffectType.Throw, Color = effColor, TargetId = Id, PosA = target }, null); Owner.Timers.Add(new WorldTimer(1500, (world, t) => { var trap = new Trap( this, eff.Radius, eff.TotalDamage, eff.ConditionEffect ?? ConditionEffectIndex.Slowed, eff.EffectDuration); trap.Move(target.X, target.Y); world.EnterWorld(trap); })); } break; case ActivateEffects.StasisBlast: { var pkts = new List<Packet>(); var effColor = new ARGB(0xffffffff); if (eff.Color != null) effColor = new ARGB((uint)eff.Color); pkts.Add(new ShowEffectPacket { EffectType = EffectType.Concentrate, TargetId = Id, PosA = target, PosB = new Position { X = target.X + 3, Y = target.Y }, Color = effColor }); BehaviorBase.AOE(Owner, target, 3, false, enemy => { if (enemy.HasConditionEffect(ConditionEffects.StasisImmune)) { pkts.Add(new NotificationPacket { ObjectId = enemy.Id, Color = new ARGB(0xff00ff00), Text = "Immune" }); } else if (enemy.isPet) { } else if (!enemy.HasConditionEffect(ConditionEffects.Stasis)) { enemy.ApplyConditionEffect( new ConditionEffect { Effect = ConditionEffectIndex.Stasis, DurationMS = eff.DurationMS }, new ConditionEffect { Effect = ConditionEffectIndex.Confused, DurationMS = eff.DurationMS } ); Owner.Timers.Add(new WorldTimer(eff.DurationMS, (world, t) => { enemy.ApplyConditionEffect(new ConditionEffect { Effect = ConditionEffectIndex.StasisImmune, DurationMS = 3000 } ); } )); pkts.Add(new NotificationPacket { ObjectId = enemy.Id, Color = new ARGB(0xffff0000), Text = "Stasis" }); } }); Owner.BroadcastPackets(pkts, null); } break; case ActivateEffects.Decoy: { var decoy = new Decoy(this, eff.DurationMS, statsMgr.GetSpeed()); decoy.Move(X, Y); Owner.EnterWorld(decoy); } break; case ActivateEffects.MultiDecoy: { for (var i = 0; i < eff.Amount; i++) { var decoy = Decoy.DecoyRandom(this, eff.DurationMS, statsMgr.GetSpeed()); decoy.Move(X, Y); Owner.EnterWorld(decoy); } } break; case ActivateEffects.Lightning: { Enemy start = null; var angle = Math.Atan2(target.Y - Y, target.X - X); var diff = Math.PI / 3; BehaviorBase.AOE(Owner, target, 6, false, enemy => { if (!(enemy is Enemy)) return; var x = Math.Atan2(enemy.Y - Y, enemy.X - X); if (Math.Abs(angle - x) < diff) { start = enemy as Enemy; diff = Math.Abs(angle - x); } }); if (start == null) break; var current = start; var targets = new Enemy[eff.MaxTargets]; for (var i = 0; i < targets.Length; i++) { targets[i] = current; float dist = 8; var next = BehaviorBase.GetNearestEntity(current, ref dist, false, enemy => enemy is Enemy && Array.IndexOf(targets, enemy) == -1 && BehaviorBase.Dist(this, enemy) <= 6) as Enemy; if (next == null) break; current = next; } var pkts = new List<Packet>(); for (var i = 0; i < targets.Length; i++) { if (targets[i] == null) break; var prev = i == 0 ? (Entity)this : targets[i - 1]; targets[i].Damage(this, time, eff.TotalDamage, false); if (eff.ConditionEffect != null) targets[i].ApplyConditionEffect(new ConditionEffect { Effect = eff.ConditionEffect.Value, DurationMS = (int)(eff.EffectDuration * 1000) }); var shotColor = new ARGB(0xffff0088); if (eff.Color != null) shotColor = new ARGB((uint)eff.Color); pkts.Add(new ShowEffectPacket { EffectType = EffectType.Lightning, TargetId = prev.Id, Color = shotColor, PosA = new Position { X = targets[i].X, Y = targets[i].Y }, PosB = new Position { X = 350 } }); } Owner.BroadcastPackets(pkts, null); } break; case ActivateEffects.PoisonGrenade: { try { Owner.BroadcastPacket(new ShowEffectPacket { EffectType = EffectType.Throw, Color = new ARGB(0xffddff00), TargetId = Id, PosA = target }, null); var x = new Placeholder(1500); x.Move(target.X, target.Y); Owner.EnterWorld(x); Owner.Timers.Add(new WorldTimer(1500, (world, t) => { try { Owner.BroadcastPacket(new ShowEffectPacket { EffectType = EffectType.AreaBlast, Color = new ARGB(0xffddff00), TargetId = x.Id, PosA = new Position { X = eff.Radius } }, null); } catch (Exception ex) { Logger.Error(ex); } var enemies = new List<Enemy>(); BehaviorBase.AOE(world, target, eff.Radius, false, enemy => PoisonEnemy(enemy as Enemy, eff)); })); } catch (Exception ex) { Logger.Error(ex); } } break; case ActivateEffects.RemoveNegativeConditions: { BehaviorBase.AOE(Owner, this, eff.Range, true, player => { ApplyConditionEffect(NegativeEffs); }); Owner.BroadcastPacket(new ShowEffectPacket { EffectType = EffectType.AreaBlast, TargetId = Id, Color = new ARGB(0xffffffff), PosA = new Position { X = eff.Range } }, null); } break; case ActivateEffects.RemoveNegativeConditionsSelf: { ApplyConditionEffect(NegativeEffs); Owner.BroadcastPacket(new ShowEffectPacket { EffectType = EffectType.AreaBlast, TargetId = Id, Color = new ARGB(0xffffffff), PosA = new Position { X = 1 } }, null); } break; case ActivateEffects.IncrementStat: { var idx = -1; switch ((StatsType)eff.Stats) { case StatsType.MaximumHP: idx = 0; break; case StatsType.MaximumMP: idx = 1; break; case StatsType.Attack: idx = 2; break; case StatsType.Defense: idx = 3; break; case StatsType.Speed: idx = 4; break; case StatsType.Vitality: idx = 5; break; case StatsType.Wisdom: idx = 6; break; case StatsType.Dexterity: idx = 7; break; } Stats[idx] += eff.Amount; var limit = int.Parse( XmlData.TypeToElement[ObjectType].Element(StatsManager.StatsIndexToName(idx)) .Attribute("max") .Value); if (Stats[idx] > limit) Stats[idx] = limit; UpdateCount++; } break; case ActivateEffects.Create: //this is a portal { short objType; if (!XmlData.IdToObjectType.TryGetValue(eff.Id, out objType) || !XmlData.Portals.ContainsKey(objType)) break; // object not found, ignore var entity = Resolve(objType); var w = RealmManager.GetWorld(Owner.Id); //can't use Owner here, as it goes out of scope var TimeoutTime = XmlData.Portals[objType].TimeoutTime; var DungName = XmlData.Portals[objType].DungeonName; ARGB c; c.A = 0; c.B = 91; c.R = 233; c.G = 176; if (eff.Id == "Wine Cellar Portal") //wine cellar incantation { var opened = false; foreach (var i in w.StaticObjects) { if (i.Value.ObjectType == 0x0721) //locked wine cellar portal { opened = true; entity.Move(i.Value.X, i.Value.Y); w.EnterWorld(entity); w.LeaveWorld(i.Value); UpdateCount++; } } if (opened) { Client.SendPacket(new NotificationPacket { Color = c, Text = DungName + " opened by " + Client.Account.Name, ObjectId = Client.Player.Id }); w.BroadcastPacket(new TextPacket { BubbleTime = 0, Stars = -1, Name = "", Text = DungName + " opened by " + Client.Account.Name }, null); w.Timers.Add(new WorldTimer(TimeoutTime * 1000, (world, t) => //default portal close time * 1000 { try { w.LeaveWorld(entity); } catch { Logger.Error("Portal couldnt despawn"); } })); } } else { entity.Move(X, Y); w.EnterWorld(entity); Client.SendPacket(new NotificationPacket { Color = c, Text = DungName + " opened by " + Client.Account.Name, ObjectId = Client.Player.Id }); w.BroadcastPacket(new TextPacket { BubbleTime = 0, Stars = -1, Name = "", Text = DungName + " opened by " + Client.Account.Name }, null); w.Timers.Add(new WorldTimer(TimeoutTime * 1000, (world, t) => //default portal close time * 1000 { try { w.LeaveWorld(entity); } catch { Logger.Error("Portal couldnt despawn"); } })); } } break; case ActivateEffects.Dye: { if (item.Texture1 != 0) { Texture1 = item.Texture1; } if (item.Texture2 != 0) { Texture2 = item.Texture2; } SaveToCharacter(); } break; case ActivateEffects.PartyAOE: { var randomnumber = Random.Next(1, 5); ConditionEffectIndex partyeffect = 0; var color = 0xffffffff; if (randomnumber == 1) { partyeffect = ConditionEffectIndex.Damaging; color = 0xffff0000; } if (randomnumber == 2) { color = 0xff00ff00; partyeffect = ConditionEffectIndex.Speedy; } if (randomnumber == 3) { color = 0xffffd800; partyeffect = ConditionEffectIndex.Berserk; } if (randomnumber == 4) { color = 0xff00ffff; partyeffect = ConditionEffectIndex.Healing; } BehaviorBase.AOE(Owner, this, eff.Range, true, player => { player.ApplyConditionEffect(new ConditionEffect { Effect = partyeffect, DurationMS = eff.DurationMS }); }); Owner.BroadcastPacket(new ShowEffectPacket { EffectType = EffectType.AreaBlast, TargetId = Id, Color = new ARGB(color), PosA = new Position { X = eff.Range } }, null); } break; case ActivateEffects.ShurikenAbility: { var w = RealmManager.GetWorld(Owner.Id); ApplyConditionEffect(new ConditionEffect { Effect = ConditionEffectIndex.Speedy, DurationMS = eff.DurationMS }); var pt = eff.ObjectId; short obj; XmlData.IdToObjectType.TryGetValue(pt, out obj); var substitute = Resolve(obj); substitute.PlayerOwner = this; substitute.isPet = true; w.EnterWorld(substitute); substitute.Move(X, Y); targetlink = target; } break; case ActivateEffects.TomeDamage: { var pkts = new List<Packet>(); BehaviorBase.AOE(Owner, this, eff.Range, false, enemy => { (enemy as Enemy).Damage(this, time, (int)statsMgr.GetAttackDamage(eff.TotalDamage, eff.TotalDamage), false); }); pkts.Add(new ShowEffectPacket { EffectType = EffectType.AreaBlast, TargetId = Id, Color = new ARGB(0xFF00FF00), PosA = new Position { X = eff.Range } }); Owner.BroadcastPackets(pkts, null); } break; case ActivateEffects.Mushroom: { var w = RealmManager.GetWorld(Owner.Id); Size = eff.Amount; UpdateCount++; w.Timers.Add(new WorldTimer(eff.DurationMS, (world, t) => { try { Size = 100; UpdateCount++; } catch { } })); } break; case ActivateEffects.PearlAbility: { var w = RealmManager.GetWorld(Owner.Id); var pt = eff.ObjectId; short obj; XmlData.IdToObjectType.TryGetValue(pt, out obj); var substitute = Resolve(obj); substitute.PlayerOwner = this; substitute.isPet = true; w.EnterWorld(substitute); substitute.Move(X, Y); targetlink = target; var pkts = new List<Packet>(); ActivateHealHp(this, eff.Amount, pkts); Owner.BroadcastPackets(pkts, null); } break; case ActivateEffects.PermaPet: { Client.Character.Pet = XmlData.IdToObjectType[eff.ObjectId]; GivePet(XmlData.IdToObjectType[eff.ObjectId]); UpdateCount++; } break; case ActivateEffects.MiniPot: { Client.Player.Stats[1] = 1; Client.Player.Stats[0] = 1; Client.Player.Stats[6] = 1; Client.Player.Stats[7] = 1; Client.Player.Stats[2] = 1; Client.Player.Stats[3] = 1; Client.Player.Stats[5] = 1; Client.Player.Stats[4] = 1; } break; case ActivateEffects.Backpack: { var bps = 1; foreach (var i in Client.Character.Backpacks) { if (bps < i.Key) bps = i.Key; } Client.Character.Backpacks.Add(bps + 1, new short[] { -1, -1, -1, -1, -1, -1, -1, -1 }); new Database().SaveBackpacks(Client.Character, Client.Account); SendInfo("Added backpack #" + (bps + 1)); } break; case ActivateEffects.Drake: { var w = RealmManager.GetWorld(Owner.Id); var pt = eff.ObjectId; short obj; XmlData.IdToObjectType.TryGetValue(pt, out obj); var drake = Resolve(obj); drake.PlayerOwner = this; w.EnterWorld(drake); drake.Move(X, Y); Owner.BroadcastPacket(new ShowEffectPacket { TargetId = Id, Color = new ARGB(0x9195A9), EffectType = EffectType.AreaBlast, PosA = new Position { X = 1 } }, null); Owner.Timers.Add(new WorldTimer(eff.DurationMS, (world, t) => { w.LeaveWorld(drake); })); } break; case ActivateEffects.BuildTower: { var w = RealmManager.GetWorld(Owner.Id); var pt = eff.ObjectId; short obj; XmlData.IdToObjectType.TryGetValue(pt, out obj); var tower = Resolve(obj); tower.PlayerOwner = this; tower.isPet = true; w.EnterWorld(tower); tower.Move(X, Y); Owner.Timers.Add(new WorldTimer(eff.DurationMS, (world, t) => { w.LeaveWorld(tower); })); } break; case ActivateEffects.MonsterToss: { var w = RealmManager.GetWorld(Owner.Id); var pt = eff.ObjectId; short obj; XmlData.IdToObjectType.TryGetValue(pt, out obj); var monster = Resolve(obj); Owner.BroadcastPacket(new ShowEffectPacket { EffectType = EffectType.Throw, Color = new ARGB(0x000000), TargetId = Id, PosA = target }, null); Owner.Timers.Add(new WorldTimer(1500, (world, t) => { w.EnterWorld(monster); monster.Move(target.X, target.Y); })); } break; case ActivateEffects.Halo: { var halo = new Halo(this, eff.Range, eff.Amount, eff.DurationMS); halo.Move(X, Y); Owner.EnterWorld(halo); } break; case ActivateEffects.Fame: { CurrentFame = Client.Account.Stats.Fame = new Database().UpdateFame(Client.Account, eff.Amount); } break; case ActivateEffects.SamuraiAbility: { var ydist = target.Y - Y; var xdist = target.X - X; var xwalkable = target.X + xdist / 2; var ywalkable = target.Y + ydist / 2; var tile = Owner.Map[(int)xwalkable, (int)ywalkable]; ObjectDesc desc; if (XmlData.Tiles[tile.TileId].NoWalk) return; if (XmlData.ObjectDescs.TryGetValue(tile.ObjType, out desc)) { if (!desc.Static) return; } Owner.BroadcastPacket(new ShowEffectPacket { EffectType = EffectType.Diffuse, Color = new ARGB(0xFFFF0000), TargetId = Id, PosA = target, PosB = new Position { X = target.X + eff.Radius, Y = target.Y } }, null); BehaviorBase.AOE(Owner, target, eff.Radius, false, enemy => { (enemy as Enemy).Damage(this, time, eff.TotalDamage, false, new ConditionEffect { Effect = ConditionEffectIndex.Bleeding, DurationMS = eff.DurationMS }); }); Move(target.X + xdist / 2, target.Y + ydist / 2); UpdateCount++; Owner.BroadcastPackets(new Packet[] { new GotoPacket { ObjectId = Id, Position = new Position { X = X, Y = Y } }, new ShowEffectPacket { EffectType = EffectType.Teleport, TargetId = Id, PosA = new Position { X = X, Y = Y }, Color = new ARGB(0xFFFFFFFF) } }, null); ApplyConditionEffect(new ConditionEffect { Effect = ConditionEffectIndex.Paralyzed, DurationMS = eff.DurationMS2 }); } break; case ActivateEffects.Summon: { var summons = 0; foreach (var i in Owner.EnemiesCollision.HitTest(X, Y, 20)) { if (i.PlayerOwner == this && i.isSummon) { summons++; } } if (summons > 2) { return; } var w = RealmManager.GetWorld(Owner.Id); var pt = eff.ObjectId + " Summon"; short obj; XmlData.IdToObjectType.TryGetValue(pt, out obj); var summon = Resolve(obj); summon.PlayerOwner = this; summon.isPet = true; summon.isSummon = true; w.EnterWorld(summon); summon.Move(X, Y); Owner.Timers.Add(new WorldTimer(eff.DurationMS, (world, t) => { w.LeaveWorld(summon); })); } break; case ActivateEffects.ChristmasPopper: { var pkts = new List<Packet>(); pkts.Add(new ShowEffectPacket { EffectType = EffectType.Diffuse, Color = new ARGB(0xFFFF0000), TargetId = Id, PosA = new Position { X = X, Y = Y }, PosB = new Position { X = X + 3, Y = Y + 3 } }); pkts.Add(new ShowEffectPacket { EffectType = EffectType.Diffuse, Color = new ARGB(0x0000FF), TargetId = Id, PosA = new Position { X = X, Y = Y }, PosB = new Position { X = X + 4, Y = Y + 4 } }); pkts.Add(new ShowEffectPacket { EffectType = EffectType.Diffuse, Color = new ARGB(0x008000), TargetId = Id, PosA = new Position { X = X, Y = Y }, PosB = new Position { X = X + 5, Y = Y + 5 } }); Owner.BroadcastPackets(pkts, null); } break; case ActivateEffects.Belt: { Player start = null; var angle = Math.Atan2(target.Y - Y, target.X - X); var diff = Math.PI / 3; BehaviorBase.AOE(Owner, target, 6, true, player => { if (!(player is Player) || player.Id == Id) return; var x = Math.Atan2(player.Y - Y, player.X - X); if (Math.Abs(angle - x) < diff) { start = player as Player; diff = Math.Abs(angle - x); } }); if (start == null) break; var current = start; var targets = new Player[eff.MaxTargets]; for (var i = 0; i < targets.Length; i++) { targets[i] = current; float dist = 8; var next = BehaviorBase.GetNearestEntity(current, ref dist, false, player => player is Player && Array.IndexOf(targets, player) == -1 && BehaviorBase.Dist(this, player) <= 6) as Player; if (next == null) break; current = next; } var pkts = new List<Packet>(); for (var i = 0; i < targets.Length; i++) { if (targets[i] == null) break; var prev = i == 0 ? (Entity)this : targets[i - 1]; targets[i].ApplyConditionEffect(new ConditionEffect { Effect = ConditionEffectIndex.Blessed, DurationMS = (int)(eff.EffectDuration * 1000) }); var shotColor = new ARGB(0xffd700); if (eff.Color != null) shotColor = new ARGB((uint)eff.Color); pkts.Add(new ShowEffectPacket { EffectType = EffectType.Lightning, TargetId = prev.Id, Color = shotColor, PosA = new Position { X = targets[i].X, Y = targets[i].Y }, PosB = new Position { X = 350 } }); } ApplyConditionEffect(new ConditionEffect { Effect = ConditionEffectIndex.Blessed, DurationMS = (int)(eff.EffectDuration * 1000) }); } break; case ActivateEffects.Totem: { short obj; var pt = eff.ObjectId2; XmlData.IdToObjectType.TryGetValue(pt, out obj); var totem = new Totem(this, eff.Range, eff.Amount, eff.ObjectId, obj); totem.isSummon = true; totem.Move(X, Y); Owner.EnterWorld(totem); } break; case ActivateEffects.UnlockPortal: { var LockedId = XmlData.IdToObjectType[eff.LockedName]; var DungeonId = XmlData.IdToObjectType[eff.DungeonName]; var w = RealmManager.GetWorld(Owner.Id); Entity entity = null; var opened = false; foreach (var i in w.StaticObjects) { if (i.Value.ObjectType != XmlData.IdToObjectType[eff.LockedName]) continue; entity = Resolve(XmlData.IdToObjectType[eff.DungeonName]); opened = true; entity.Move(i.Value.X, i.Value.Y); w.EnterWorld(entity); w.LeaveWorld(i.Value); UpdateCount++; break; } if (opened) { w.BroadcastPacket(new NotificationPacket { Color = new ARGB(0xFF00FF00), Text = "Unlocked by " + Client.Account.Name, ObjectId = Client.Player.Id }, null); w.BroadcastPacket(new TextPacket { BubbleTime = 0, Stars = -1, Name = "", Text = eff.DungeonName + " unlocked by " + Client.Account.Name }, null); w.Timers.Add(new WorldTimer(XmlData.Portals[DungeonId].TimeoutTime * 1000, (world, t) => //default portal close time * 1000 { try { w.LeaveWorld(entity); } catch { Logger.Error("Portal couldnt despawn"); } })); } } break; } } UpdateCount++; }
Vector3? OnMyTurn(Totem totem) { // find a target var desire = new Dictionary<Vector2, float>(); int otherPlayer = totem.Owner == TerrainGrid.ServerPlayerId ? TerrainGrid.ClientPlayerId : TerrainGrid.ServerPlayerId; Vector2 mySummoner = CoordOf(TerrainGrid.Instance.Summoners[totem.Owner]); Vector2 otherSummoner = CoordOf(TerrainGrid.Instance.Summoners[otherPlayer]); Vector2 myCoord = CoordOf(totem); float intelligence = totem.TotemIntelligence/6.0f; float wantToKillSummoner = intelligence; float wantToDefendSummoner = 1-intelligence; foreach(Totem t in TerrainGrid.Instance.Totems[otherPlayer]) { desire[CoordOf(t)] = wantToDefendSummoner*(Closeness(mySummoner, CoordOf(t)) + Closeness(myCoord, CoordOf(t))); } desire[otherSummoner] = wantToKillSummoner * Closeness(myCoord, otherSummoner); Vector2 target = desire.OrderByDescending(x => x.Value).First().Key; //string msg = ""; //foreach(KeyValuePair<Vector2, float> k in desire) //{ // msg += k + " "; //} //msg += "\n" + target; //print(msg); // now we have a target! go there! float edgeNoise = Mathf.Pow(10, 5-totem.TotemIntelligence); Vector2 source = CoordOf(totem); TerrainGrid grid = TerrainGrid.Instance; IShortestPathGraph<Vector2> graph = new DijkstraShortestPathGraph<Vector2>(); for(int i = 0; i < grid.sizeX; i++) for(int j = 0; j < grid.sizeZ; j++) graph.AddNode(new Vector2(i, j)); for(int i = 0; i < grid.sizeX; i++) for(int j = 0; j < grid.sizeZ; j++) { if(i < grid.sizeX-1) { if(Mathf.Abs(TerrainGrid.GetHeightAt(i, j) - TerrainGrid.GetHeightAt(i+1, j)) < 1.01f && (TerrainGrid.IsWalkable(i, j) || source == new Vector2(i, j) || target == new Vector2(i, j)) && (TerrainGrid.IsWalkable(i+1, j) || source == new Vector2(i+1, j) || target == new Vector2(i+1, j))) { Debug.DrawLine( new Vector3(i+0.5f, TerrainGrid.GetHeightAt(i, j), j+0.5f), new Vector3(i+1.5f, TerrainGrid.GetHeightAt(i+1, j), j+0.5f), Color.red, 1, false); float weight = 1+edgeNoise*Random.value; graph.AddEdge(new Vector2(i, j), new Vector2(i+1, j), weight); graph.AddEdge(new Vector2(i+1, j), new Vector2(i, j), weight); } } if(j < grid.sizeZ-1) { if(Mathf.Abs(TerrainGrid.GetHeightAt(i, j) - TerrainGrid.GetHeightAt(i, j+1)) < 1.01f && (TerrainGrid.IsWalkable(i, j) || source == new Vector2(i, j) || target == new Vector2(i, j)) && (TerrainGrid.IsWalkable(i, j+1) || source == new Vector2(i, j+1) || target == new Vector2(i, j+1))) { Debug.DrawLine( new Vector3(i+0.5f, TerrainGrid.GetHeightAt(i, j), j+0.5f), new Vector3(i+0.5f, TerrainGrid.GetHeightAt(i, j+1), j+1.5f), Color.red, 1, false); float weight = 1+edgeNoise*Random.value; graph.AddEdge(new Vector2(i, j), new Vector2(i, j+1), weight); graph.AddEdge(new Vector2(i, j+1), new Vector2(i, j), weight); } } } IList<Vector2> path = graph.GetPath(source, target); if(path == null) return null; Vector2 direction = path[1] - path[0]; if (path.Count > 2) networkView.RPC("MoveTo", RPCMode.All, new Vector3(direction.x, 0, direction.y)); else return new Vector3(direction.x, 0, direction.y); return null; }
Vector2 CoordOf(Totem totem) { return new Vector2(totem.Cell.X, totem.Cell.Z); }
public void SetIdle(bool isIdle) { if (isIdle) { if(caughtTotem!=null) { caughtTotem.ReleasedByPlayer(); PlaceTotemSound(); caughtTotem = null; } mode = IDLE; speed = idleSpeed; StopSweating(); CatchTotemSoundLoop(false); } else { mode = CATCH; speed = catchSpeed; StartSweating(); CatchTotemSoundLoop(true); } }
public void Catch(){ if (mode == IDLE && !inMoveThread &&!isMoving && Mathf.Abs(dir.x+dir.y)==1 ) { IntVector2 actionPos = pos + dir; List<Character> charList = Map.Seek (actionPos); foreach (Character c in charList) { // If there's a totem in front of Player if (c is Totem) { //Debug.Log("Caught"); caughtTotem = (Totem)c; caughtTotem.CaughtByPlayer (); SetIdle(false); break; } } } else if(mode == CATCH && !inMoveThread && !isMoving) { //Debug.Log("Dismiss"); SetIdle(true); } }
public bool IsEnemy(Totem other) { return other.Owner != Owner; }
void Update() { float moveH = Input.GetAxis ("Horizontal"); float moveV = Input.GetAxis ("Vertical"); if ( !(Mathf.Abs(moveH) == 0.0f && Mathf.Abs(moveV) == 0.0f) && !isMoving) { int unitH = moveH==0.0f? 0 : (moveH>0.0f? 1 : -1); int unitV = moveV==0.0f? 0 : (moveV>0.0f? 1 : -1); IntVector2 movement = new IntVector2 (unitH, unitV); if(movement!=dir && mode!=CATCH) { Rotate (movement); } else { if(mode == CATCH) { // Slant move is not allowed when CATCH if( Mathf.Abs(movement.x+movement.y)==1 ) MoveByVector(movement); } else { MoveByVector(movement); } } } // Plant a totem when pressing left ctrl and not moving and not slant if (Input.GetKeyDown (KeyCode.LeftControl) && !isMoving && ( Mathf.Abs(dir.x+dir.y)==1)) { IntVector2 plantPos = Map.BoundPos(pos+dir); // If the grid is empty if(Map.mainMap [plantPos.x, plantPos.y].Count==0) { GameObject totemObj = Instantiate (totem, totemSpawn.position, Quaternion.Euler(0f,0f,0f)) as GameObject; Totem newTotem = totemObj.GetComponent<Totem>(); newTotem.pos = pos+dir; newTotem.dir = new IntVector2(0,-1); newTotem.isCaught = false; newTotem.playerRef = this; Map.mainMap [pos.x+dir.x, pos.y+dir.y].Add (newTotem); } } // Catch or release the totem when pressing Space key if (Input.GetKeyDown (KeyCode.Space) && !isMoving) { IntVector2 actionPos = pos+dir; switch(mode) { case IDLE: foreach(Character c in Map.mainMap[actionPos.x, actionPos.y]) { // If there's a totem in front of Player if(c.GetType() == typeof(Totem)) { caughtTotem = (Totem)c; caughtTotem.transform.parent = transform; caughtTotem.isCaught = true; mode = CATCH; break; } } break; case CATCH: caughtTotem.transform.parent = null; caughtTotem.isCaught = false; caughtTotem = null; mode = IDLE; break; } } }
private static string GetIconFor(Totem totem) { return totem.ToString().ToLower() + ".png"; }
public static void SetTotemSlot(MultiCastSlot slot, Totem spellID) { WoWScript.ExecuteNoResults("SetMultiCastSpell(" + (int)slot + ", " + (int)spellID + ")"); }