private void OnCollisionEnter(Collision other) { int otherLayer = other.gameObject.layer; Vulnerable obj = other.gameObject.GetComponent <Vulnerable>(); Player objp = other.gameObject.GetComponent <Player>(); if (otherLayer == LayerMask.NameToLayer("Bullet")) { Destroy(other.gameObject); } if (otherLayer == LayerMask.NameToLayer("Player")) { if (objp != null) { StartCoroutine(instBullet.DealEffect(objp)); } } if (obj != null) { obj.Damage(damage); } transform.position = transform.position + new Vector3(500, 500, 500); StartCoroutine(Dead()); }
/// <summary> /// Calculates how susceptible something is based on the current /// resistances (<see cref="Immune"/> etc). /// </summary> /// <param name="s"></param> /// <returns>0 for immunity, 1 for normal. 0.5 for resist and 2 for vulnerable</returns> public double Calculate(IHasStats s) { //if you are immune if (Immune.Any(s.Has)) { return(0); } bool resist = Resist.Any(s.Has); bool vuln = Vulnerable.Any(s.Has); if (resist && vuln) { return(1); } if (resist) { return(0.5); } if (vuln) { return(2); } //neither resistant nor vulnerable return(1); }
public void OnCollisionEnter2D(Collision2D collision) { if (_waitForNotBlocked || controller.movementController.IsGrounded) { return; } ContactFilter2D filter = new ContactFilter2D(); filter.layerMask = enemyLayerMask; int contacts = attackCollider.Cast(controller.movementController.Velocity.normalized, filter, _hits, 0.25f); for (int i = 0; i < contacts; i++) { if (_hits[i].collider.gameObject.tag == "Enemy") { Vulnerable consumer = _hits[i].collider.gameObject.GetComponent <Vulnerable>(); if (consumer) { consumer.RecieveAttack(_isSlamming ? AttackType.Slam : AttackType.Jump, attackCollider, _hits[i]); if (_isSlamming) { _waitForNotBlocked = true; } break; } } } _isSlamming = false; }
/// <summary> /// Calculates how susceptible something is based on the current /// resistances (<see cref="Immune"/> etc). This overload lets you /// omit item adjectives /// </summary> /// <param name="a"></param> /// <param name="includeItems">True to include items you are carrying when /// considering if you meet the immunities</param> /// <returns>0 for immunity, 1 for normal. 0.5 for resist and 2 for vulnerable</returns> public double Calculate(IActor a, bool includeItems) { //if you are immune if (Immune.Any(i => a.Has(i, includeItems))) { return(0); } bool resist = Resist.Any(i => a.Has(i, includeItems)); bool vuln = Vulnerable.Any(i => a.Has(i, includeItems)); if (resist && vuln) { return(1); } if (resist) { return(0.5); } if (vuln) { return(2); } //neither resistant nor vulnerable return(1); }
public bool Punch() { if (!hasPunch) { return(false); } Vector2 direction = Vector2.right * controller.movementController.LastDirection; float lungeForce = controller.movementController.IsBlocked ? _punchLungeForce : _airPunchLunchForce; controller.movementController.AddForce(direction * lungeForce); int contacts = Physics2D.BoxCastNonAlloc(transform.position, Vector2.one * 0.75f, 0, direction, _hits, _punchDistance, enemyLayerMask); for (int i = 0; i < contacts; i++) { if (_hits[i].collider.gameObject.tag == "Enemy") { Vulnerable consumer = _hits[i].collider.gameObject.GetComponent <Vulnerable>(); if (consumer) { consumer.RecieveAttack(AttackType.Punch, attackCollider, _hits[i]); Debug.DrawLine(transform.position, consumer.transform.position, Color.red, 2.0f); return(true); } } } Debug.DrawLine(transform.position, transform.position + ((Vector3)direction * _punchDistance), Color.blue, 2.0f); return(true); }
/// <summary> /// Read a board from a string. /// The string must have the dealer and vulnerability on the first line /// E,Both /// s 753 /// h KT53 /// d T654 /// c K6 /// s T984 s AKQJ62 /// h 842 h AQ7 /// d AQ d 3 /// c AQJ7 c 543 /// s /// h J96 /// d K9872 /// c T982 /// </summary> public Board2(string diagram) { if (diagram == null) { throw new ArgumentNullException("diagram"); } this.theDistribution = new Distribution(); this.results = new Collection <BoardResult>(); string[] lines = diagram.Replace("\r", "").Replace("\t", " ").Split('\n'); string[] contract = lines[0].Split(','); ParseSuit(lines[01].Trim(), Seats.North); ParseSuit(lines[02].Trim(), Seats.North); ParseSuit(lines[03].Trim(), Seats.North); ParseSuit(lines[04].Trim(), Seats.North); ParseSuit(lines[09].Trim(), Seats.South); ParseSuit(lines[10].Trim(), Seats.South); ParseSuit(lines[11].Trim(), Seats.South); ParseSuit(lines[12].Trim(), Seats.South); ParseSuit(lines[05].Substring(00, 17).Trim(), Seats.West); ParseSuit(lines[06].Substring(00, 17).Trim(), Seats.West); ParseSuit(lines[07].Substring(00, 17).Trim(), Seats.West); ParseSuit(lines[08].Substring(00, 17).Trim(), Seats.West); ParseSuit(lines[05].Substring(17).Trim(), Seats.East); ParseSuit(lines[06].Substring(17).Trim(), Seats.East); ParseSuit(lines[07].Substring(17).Trim(), Seats.East); ParseSuit(lines[08].Substring(17).Trim(), Seats.East); this.theDealer = SeatsExtensions.FromXML(contract[0].Trim()); this.theVulnerability = VulnerableConverter.FromXML(contract[1].Trim()); }
private int theBoardId; // used for storage (absolute to table) public Board2(Seats dealer, Vulnerable vulnerability, Distribution distribution) : this() { this.theDealer = dealer; this.theVulnerability = vulnerability; this.theDistribution = distribution; }
public Board2(int boardNumber) : this() { this.theDealer = SeatsExtensions.DealerFromBoardNumber(boardNumber); this.theVulnerability = VulnerableConverter.FromBoardNumber(boardNumber); this.theBoardNumber = boardNumber; this.theDistribution.DealRemainingCards(ShufflingRequirement.Random); }
private void onHit(Vulnerable vulnerable) { cubesPull.ReleaseObject(vulnerable); if (vulnerable.OnHit != null) { vulnerable.OnHit -= onHit; } }
public Board2() { this.theDealer = Seats.North; this.theVulnerability = Vulnerable.Both; this.theDistribution = new Distribution(); this.results = new Collection <BoardResult>(); this.theBoardNumber = 1; }
public override void HandleBoardStarted(int boardNumber, Seats dealer, Vulnerable vulnerabilty) { if (this.Board == null) { this.Dealer = dealer; this.Vulnerability = vulnerabilty; this.theAuction = new Auction(this.Vulnerability, this.Dealer); } }
public GoblinSorcerer(string name, string job, int maxHealth, ETargetType targetType) : base(name, job, maxHealth, targetType) { Abilities[0] = new Vulnerable(new Bare("Head", "Your bare head")); Abilities[1] = new Regular(new IceBeam()); Abilities[2] = new Regular(new LightningBolt()); Abilities[3] = new Evade(new Spring(), 0.25f); Abilities[4] = new Vulnerable(new Bare("Chest", "Your bare chest")); Abilities[5] = new Vulnerable(new Bare("Back", "Your bare back")); }
// Update is called once per frame void Update() { delay += Time.deltaTime; if (delay >= emitionDelay) { delay = 0; Vulnerable cube = CreateCube(); } }
public Sorcerer(string name, int maxHealth, ETargetType targetType) : base(name, "Sorcerer", maxHealth, targetType) { Abilities[0] = new Regular(new DragonsBreath()); Abilities[1] = new Regular(new IceBeam()); Abilities[2] = new Regular(new LightningBolt()); Abilities[3] = new Evade(new Spring(), 0.25f); Abilities[4] = new Vulnerable(new Bare("Chest", "Your bare chest")); Abilities[5] = new Vulnerable(new Bare("Back", "Your bare back")); }
public Cleric(string name, int maxHealth, ETargetType targetType) : base(name, "Cleric", maxHealth, targetType) { Abilities[0] = new Regular(new Prayer()); Abilities[1] = new Armored(new Shieldslam(), 3); Abilities[2] = new Regular(new Heal()); Abilities[3] = new Evade(new Dodge(), 0.25f); Abilities[4] = new Armored(new Bare("Chest", "Bare Chest"), 3); Abilities[5] = new Vulnerable(new Bare("Back", "Your bare back")); }
public Warrior(string name, int maxHealth, ETargetType targetType) : base(name, "Warrior", maxHealth, targetType) { Abilities[0] = new Regular(new Headbutt()); Abilities[1] = new Armored(new Shieldslam(), 3); Abilities[2] = new Regular(new Slash()); Abilities[3] = new Regular(new Kick()); Abilities[4] = new Regular(new Tackle()); Abilities[5] = new Vulnerable(new Bare("Back", "Your bare back")); }
public override void HandleBoardStarted(int boardNumber, Seats dealer, Vulnerable vulnerabilty) { this.Add(() => { if (this.OnBoardStarted != null) { this.OnBoardStarted(boardNumber, dealer, vulnerabilty); } }); }
public static string ToBridgeProtocol(Vulnerable value) { switch ((Vulnerable)value) { case Vulnerable.Neither: return("Neither"); case Vulnerable.NS: return("N/S"); case Vulnerable.EW: return("E/W"); default: return("Both"); } }
public static Vulnerable Rotate(Vulnerable value) { switch ((Vulnerable)value) { case Vulnerable.Neither: return(Vulnerable.Neither); case Vulnerable.NS: return(Vulnerable.EW); case Vulnerable.EW: return(Vulnerable.NS); default: return(Vulnerable.Both); } }
private Vulnerable CreateCube() { Vulnerable cube = cubesPull.GetObject(); cube.transform.parent = transform; cube.transform.localScale = Vector3.one; cube.transform.localPosition = new Vector3(Random.Range(minX, maxX), startY, Random.Range(minZ, maxZ)); cube.OnHit += onHit; cube.gameObject.SetActive(true); return(cube); }
public static string ToXML(Vulnerable value) { switch ((Vulnerable)value) { case Vulnerable.Neither: return("None"); case Vulnerable.NS: return("NS"); case Vulnerable.EW: return("EW"); default: return("All"); } }
//public static string ToString(Vulnerable value) //{ // switch ((Vulnerable)value) // { // case Vulnerable.Neither: return LocalizationResources.Neither; // case Vulnerable.NS: return LocalizationResources.NS; // case Vulnerable.EW: return LocalizationResources.EW; // default: return LocalizationResources.All; // } //} /// <summary> /// Localized string /// </summary> /// <param name="value"></param> /// <returns>Localized string</returns> public static string ToString2(this Vulnerable value) { switch ((Vulnerable)value) { case Vulnerable.Neither: return(LocalizationResources.Neither); case Vulnerable.NS: return(LocalizationResources.NS); case Vulnerable.EW: return(LocalizationResources.EW); default: return(LocalizationResources.All); } }
void OnTriggerEnter(Collider c) { Vulnerable v = c.gameObject.GetComponent <Vulnerable>(); if (v != null && v.ExplodeOnCivilian) { Destroy(gameObject); GameObject o = (GameObject)Instantiate(ExplodeEffect); o.transform.Translate(gameObject.transform.position); AudioSource.PlayClipAtPoint(ExplodeSfx, Vector3.zero); LevelController lc = LevelController.GetComponent <LevelController>(); lc.HandleCivilianDestroyed(); } }
public override void HandleBoardStarted(int boardNumber, Seats dealer, Vulnerable vulnerabilty) { #if syncTrace //Log.Trace(4, "TableManagerHost.HandleBoardStarted"); #endif base.HandleBoardStarted(boardNumber, dealer, vulnerabilty); for (Seats s = Seats.North; s <= Seats.West; s++) { this.clients[s].Pause = true; this.clients[s].state = TableManagerProtocolState.WaitForStartOfBoard; } Threading.Sleep(20); this.BroadCast("Start of board"); for (Seats s = Seats.North; s <= Seats.West; s++) { this.clients[s].Pause = false; } }
public static string ToPbn(this Vulnerable v) { switch (v) { case Vulnerable.Neither: return("None"); case Vulnerable.NS: return("NS"); case Vulnerable.EW: return("EW"); case Vulnerable.Both: return("All"); default: throw new ArgumentOutOfRangeException(); } }
internal static string Translate(Vulnerable v) { switch (v) { case Vulnerable.Neither: return("Neither"); case Vulnerable.NS: return("N/S"); case Vulnerable.EW: return("E/W"); case Vulnerable.Both: return("Both"); default: throw new System.ArgumentOutOfRangeException(); } }
public void CopyBoardData(Vulnerable vulnerability, Distribution boardDistribution) { if (boardDistribution == null) { throw new ArgumentNullException("boardDistribution"); } if (this.theAuction == null) { this.theAuction = new Auction(this.Board.Vulnerable, this.Board.Dealer); } else { if (this.theAuction.Ended) { this.Contract.Vulnerability = vulnerability; this.theAuction.FinalContract.Vulnerability = vulnerability; } } this.theDistribution = boardDistribution.Clone(); }
public Contract(string fromXML, Seats de, Vulnerable v) { _declarer = de; this.theVulnerability = v; //declarerTricks = 0; defenseTricks = 0; fromXML = fromXML.ToLower(); if (fromXML == "pass") { theBid = new Bid(SpecialBids.Pass); //_doubled = false; _redoubled = false; } else { string doubled = ""; if (fromXML.IndexOf("x") > 0) { doubled = fromXML.Substring(fromXML.IndexOf("x")); fromXML = fromXML.Substring(0, fromXML.IndexOf("x")); } theBid = new Bid(fromXML.ToUpper()); if (doubled == "xx") { _doubled = true; _redoubled = true; } else if (doubled == "x") { _doubled = true; _redoubled = false; } else { _doubled = false; _redoubled = false; } } }
private static bool IsDeclarerVulnerable(Seats declarer, Vulnerable vulnerability) { return(vulnerability == Vulnerable.Both || (vulnerability == Vulnerable.NS && (declarer == Seats.North || declarer == Seats.South)) || (vulnerability == Vulnerable.EW && (declarer == Seats.East || declarer == Seats.West))); }
public Contract(Bid b, bool d, bool r, Seats declarer, Vulnerable v) { theBid = b; _doubled = d; _redoubled = r; _declarer = declarer; this.theVulnerability = v; //declarerTricks = 0; defenseTricks = 0; }