//methodes public void add_astronaut(Astronaut astro) { DateTime now = DateTime.Now; if (beginningDateEarth < now) { l_astronaut.Add(astro); } }
public void rm_astronaut(Astronaut astro) { DateTime now = DateTime.Now; if (l_astronaut.Contains(astro) && beginningDateEarth < now) l_astronaut.Remove(astro); }
public void SetUp() { this.testAstronaut = new Astronaut("Elon", 90); this.testSpaceship = new Spaceship("Falcon", 10); }
void FixedUpdate() { Astronaut plr = Astronaut.TheAstronaut; bool OnGround = false; bool cancrawl = false; foreach (Sprite c in CrawlFrames) { if (c.Equals(MySpriteRenderer.sprite)) { cancrawl = true; } } if (Alive && !isStunned()) { bool stateexpired = (Time.time >= (StateTime + StateDuration)); switch (MyState) { case State.None: { break; } case State.Waiting: { if (stateexpired) { setState(State.Crawling, .5f); StateTime = Time.time; } break; } case State.Crawling: { float sdif = (this.transform.position.x - StartPosition.x); if (GoLeftGoRight?(sdif < -LeftOffset): (sdif > -RightOffset)) //(Mathf.Abs(sdif) > 3f) { float sig = Mathf.Sign(sdif); GoLeftGoRight = (sig >= 0f); } RaycastHit2D rh = Physics2D.Linecast(this.transform.position, this.transform.position + Vector3.down * .6f, LayerMask.GetMask(new string[] { "Geometry" })); if (rh.distance <= 0f) { //in the air. } else if (rh.distance <= .6f) { //Landed if (!isStunned()) { //if (Mathf.Abs(sdif) <= 3f) MyRigidbody.velocity = new Vector2((GoLeftGoRight ? -1f : 1f) * (cancrawl? 1f:0f) * (1f - FreezeFactor) * 2f * ((.5f + (2f * Astronaut.AggressionLevelF * (Astronaut.TheAstronaut.Quelling?0f:1f)))), MyRigidbody.velocity.y); } } //MyRigidbody.AddForce(new Vector2(GoLeftGoRight ? -1f : 1f, 0f) * 10f); /* * if (stateexpired) * { * bool ch = false; * * if ((plr != null) && (plr.Alive)) * { * * * Vector3 dif = (plr.transform.position - this.transform.position); * if (dif.magnitude < 10f) * { * RaycastHit2D rh = Physics2D.Linecast(this.transform.position, plr.transform.position, LayerMask.GetMask(new string[] { "Geometry" })); * Debug.Log(rh.distance); * if (rh.distance <= 0f) * { * Debug.Log("Take aim"); * ParticleSystem s = ShootWindUpGlow; * setState(State.Firing, s.main.duration); * ch = true; * //Debug.Log("Visible"); * } else * { * Debug.Log("hiding..."); * } * } * } * if (!ch) * setState(State.FloatingBackAndForth, .5f + (2f * Random.value)); * } * */ if (MyRigidbody.velocity.x != 0f) { MySpriteRenderer.flipX = (Mathf.Sign(MyRigidbody.velocity.x) > 0f); } break; } } //MyRigidbody.velocity = new Vector2(movedir * movespeed, MyRigidbody.velocity.y); } else { setState(State.Crawling, .5f + (2f * Random.value)); } if (Alive) { if (((!IsInFirePatch) && ((Time.time - LastFirePatchDroppedTime) >= .8f)) && (!isStunned()) && (!Astronaut.TheAstronaut.Quelling)) { RaycastHit2D rh = Physics2D.Raycast(this.transform.position, Vector3.down, .3f, LayerMask.GetMask(new string[] { "Geometry" })); if (rh.collider != null) { spawnFirePatch(); } } IsInFirePatch = false; DamageFlashStep(); freezeStep(); } }
// Update is called once per frame void Update() { int moveX = 1; float moveY = 0; if (tactic == ShipTactic.Attacking) { if (attackPhase == AttackPhase.Attacking) { shooting = true; dir = transform.position.x > playerShipRuntime.Position.x ? -1 : 1; if (HP == 1 && type != EnemyType.Fighter) { tactic = ShipTactic.Fleeing; } //ship isn't in the shooting range if (Mathf.Abs(transform.position.x - playerShipRuntime.Position.x) > halfShootRange) { moveX = 1; moveY = 0; } else if (Mathf.Abs(transform.position.x - playerShipRuntime.Position.x) <= halfShootRange && Mathf.Abs(transform.position.x - playerShipRuntime.Position.x) > shootRange) { moveY = playerShipRuntime.Position.y > transform.position.y ? 1 : -1; moveX = 1; } else if (Mathf.Abs(transform.position.x - playerShipRuntime.Position.x) < backoutXRange) { moveX = 1; moveY = 0; dir = transform.position.x > playerShipRuntime.Position.x ? 1 : -1; } else { if (Mathf.Abs(playerShipRuntime.Position.y - (transform.position.y - 0.1f)) > 0.1f) { moveY = playerShipRuntime.Position.y > transform.position.y ? 1 : -1; } else { moveY = 0; } moveX = 0; } if (playerShipRuntime.Invulnerable == true) { attackPhase = AttackPhase.HitLanded; hitLandedBackoutStarted = Time.time; hitLandedStartY = transform.position.y; } else if (attackChaseStarted + attackChaseTime < Time.time) { attackPhase = AttackPhase.BackingOut; chaseFailedBackoutStarted = Time.time; } } else if (attackPhase == AttackPhase.HitLanded) { shooting = false; //ship isn't in the shooting range if (Mathf.Abs(transform.position.x - playerShipRuntime.Position.x) > shootRange) { moveX = 1; moveY = 0; } else if (Mathf.Abs(transform.position.x - playerShipRuntime.Position.x) < backoutXRange) { moveX = 1; moveY = 0; dir = transform.position.x > playerShipRuntime.Position.x ? 1 : -1; } moveY = hitLandedStartY > 0 ? -1 : 1; if (hitLandedBackoutStarted + hitLandedBackoutTime < Time.time) { attackPhase = AttackPhase.Attacking; attackChaseStarted = Time.time; } } else { shooting = false; moveX = 0; moveY = 0; if (chaseFailedBackoutStarted + chaseFailedBackoutTime < Time.time) { attackPhase = AttackPhase.Attacking; attackChaseStarted = Time.time; } } } else if (tactic == ShipTactic.PassingThrough) { if ((dir > 0 && playerShipRuntime.Position.x > transform.position.x) || (dir < 0 && playerShipRuntime.Position.x < transform.position.x)) { if (Mathf.Abs(playerShipRuntime.Position.y - transform.position.y) < 1f && playerShipRuntime.Position.y >= transform.position.y) { moveY = -1; } if (Mathf.Abs(playerShipRuntime.Position.y - transform.position.y) < 1f && playerShipRuntime.Position.y < transform.position.y) { moveY = 1; } } if (HP == 1) { tactic = ShipTactic.Fleeing; } } else if (tactic == ShipTactic.Fleeing) { if (float.IsNaN(fleeingStartY)) { fleeingStartY = transform.position.y; } if (fleeingStartY + fleeingYMax < transform.position.y) { fleeingMoveY = -1 * fleeingMoveYCoef; } else if (fleeingStartY + fleeingYMin > transform.position.y) { fleeingMoveY = 1 * fleeingMoveYCoef; } if (transform.position.x > playerShipRuntime.Position.x) { dir = 1; } else { dir = -1; } //military ships heal on fleeing mode if (type == EnemyType.Military) { if (lastHealed == 0) { lastHealed = Time.time - 5f; } if (Time.time > lastHealed + healFrequency) { HP += 1; lastHealed = Time.time; } if (HP >= healTillGood) { tactic = ShipTactic.Attacking; lastHealed = 0; } } moveY = fleeingMoveY; shooting = false; } else if (tactic == ShipTactic.Broken) { moveX = 0; moveY = 0; boardable = true; body.constraints = RigidbodyConstraints2D.FreezeAll; doCollisionDamage = false; hpMeter.gameObject.SetActive(false); boardSign.SetActive(true); dockingManager.SetDockable(this); shooting = false; } else if (tactic == ShipTactic.Explode) { foreach (GameObject explObj in explosionParts) { explObj.SetActive(true); } foreach (Transform child in transform) { SpriteRenderer renderer = child.GetComponent <SpriteRenderer>(); if (renderer != null) { renderer.enabled = false; } } if (type == EnemyType.Civilian && !spawnedAstronaut) { spawnedAstronaut = true; for (var i = 0; i < 3; i++) { Astronaut astronaut = Instantiate(astronautPrefab); Vector3 v = Random.onUnitSphere; Vector3 v2 = Vector3.Normalize(new Vector3(v.x, v.y, 0)); Vector2 x = new Vector2(v2.x, v2.y); astronaut.transform.position = transform.position; astronaut.SetDirection(x); } } doCollisionDamage = false; enemyCollider.enabled = false; shooting = false; hpMeter.gameObject.SetActive(false); boardSign.SetActive(false); moveX = 0; moveY = 0; StartCoroutine(WaitAndDestroy()); } else if (tactic == ShipTactic.TooFar) { if (playerShipRuntime.Position.x >= transform.position.x) { dir = 1; } else { dir = -1; } if ((dir > 0 && playerShipRuntime.Position.x > transform.position.x) || (dir < 0 && playerShipRuntime.Position.x < transform.position.x)) { if (Mathf.Abs(playerShipRuntime.Position.y - transform.position.y) < 1f && playerShipRuntime.Position.y >= transform.position.y) { moveY = -1; } if (Mathf.Abs(playerShipRuntime.Position.y - transform.position.y) < 1f && playerShipRuntime.Position.y < transform.position.y) { moveY = 1; } } if (Mathf.Abs(playerShipRuntime.Position.x - transform.position.x) < 10) { tactic = previousTactic; } } if (HP == 0) { if (type == EnemyType.Cargo) { tactic = ShipTactic.Broken; } else { tactic = ShipTactic.Explode; } } if (tactic != ShipTactic.Explode && tactic != ShipTactic.Broken && tactic != ShipTactic.TooFar) { if (Vector3.Distance(playerShipRuntime.Position, transform.position) > 40) { previousTactic = tactic; tactic = ShipTactic.TooFar; } } if (transform.position.y > maxY && moveY > 0) { moveY = 0; } else if (transform.position.y < minY && moveY < 0) { moveY = 0; } body.velocity = new Vector2(velocity.x * Time.deltaTime * dir * moveX, velocity.y * Time.deltaTime * moveY); hpMeter.SetHealth(HP); }
public virtual void AstronautExit(Astronaut astronaut) { _astronauts.Remove(astronaut); }
void FixedUpdate() { if (Alive && !isStunned()) { Astronaut plr = Astronaut.TheAstronaut; if (SporeAttacking) { //Release Spores if ((Time.time - SporeAttackTime) >= 1.5f) { SporeAttacking = false; //MoveDirection = 0; MyAnimator.SetBool("WingUp", false); } } else if (Attacking) { //Jumping attack //MoveDirection = ((int)Mathf.Sign(MyRigidbody.velocity.x)); if (SporeJumpLoaded) { if ((Time.time - AttackTime) >= .1f) { if (MyRigidbody.velocity.y < 0f) { SporeJumpLoaded = false; ReleaseSpores(false); } } } if ((Time.time - AttackTime) >= .75f) { Attacking = false; MyAnimator.SetBool("WingUp", false); } } else { //If the player is within range if ((plr != null) && (plr.Alive) && ((Time.time - plr.ReviveTime) >= 2f)) { Vector3 dif = (plr.transform.position - this.transform.position); tdif = dif; if (Physics2D.Linecast(this.transform.position, plr.transform.position, LayerMask.GetMask(new string[] { "Geometry" })).collider == null) { if (dif.magnitude < 6.5f) { int d = ((int)Mathf.Sign(dif.x)); if ((d != 0) && (MoveDirection == d)) { passtime = Time.time; } else { if ((Time.time - passtime) > 1f) { MoveDirection = d; } } jumpe = Mathf.Max(dif.y, 0f); if ((dif.magnitude < 4f) && (Mathf.Min((Time.time - AttackTime), (Time.time - SporeAttackTime)) > 2.5f)) { if ((Astronaut.AggressionLevel > 2) || false) { if (Random.value < .5f) { Attack(); } else { ReleaseSpores(true); } } else { Attack(); } } else { } } else { Vector3 du = (this.transform.position - StartPosition); if (Mathf.Abs(du.x) > 3f) { int d = ((int)Mathf.Sign(-du.x)); MoveDirection = d; } } } } else { MoveDirection = 0; } } //if (!Attacking) checkForEdge(); if (MoveDirection != 0) { if (!Attacking) { MyAnimator.SetBool("Moving", true); MyRigidbody.velocity = new Vector2(MoveSpeed * (1f - FreezeFactor) * MoveDirection * (.75f + (1.75f * Astronaut.AggressionLevelF)), MyRigidbody.velocity.y); this.transform.localScale = new Vector3(Mathf.Abs(this.transform.localScale.x) * Mathf.Sign(-MoveDirection), this.transform.localScale.y, this.transform.localScale.z); } } else { if (!Attacking) { MyRigidbody.velocity = new Vector2(0f, MyRigidbody.velocity.y); MyAnimator.SetBool("Moving", false); } } } else { MoveDirection = 0; MyAnimator.SetBool("Moving", false); MyAnimator.SetBool("WingUp", false); } }
public void SetsTwoAttributesFromProperty() { var mapper = new XmlMapper<Astronaut> { {"fname", "lname", a => a.Name, (f,l) => string.Format("{0} {1}", f, l), s => Split(s)}, }; var astronaut = new Astronaut {Name = "Michael Collins"}; var actual = mapper.ToXml(astronaut, "astronaut"); Assert.Equal("Michael", actual.Attribute("fname").Value); Assert.Equal("Collins", actual.Attribute("lname").Value); }
public void Setup() { this.astronaut = new Astronaut(NAME, OXYGEN); }
private void OnBulletHit(Collider2D col) { if (col == null) { return; } GenericEnemy en = col.GetComponent <GenericEnemy>(); Vector2 vec = new Vector2((this.transform.position.x - lastposition.x), (this.transform.position.y - lastposition.y)); if (en != null) { //if (col.isTrigger) return; en.TakeDamage(Damage, vec * 1f); Astronaut.TheAstronaut.tickHitMarker(Damage, (en.Health / en.MaxHealth) * (en.Alive?1f:0f), !en.Alive); GameManager.TheGameManager.ignoreTutorialTip(TutorialSystem.TutorialTip.Shoot); if (RailSlug) { ParticleSystem p = GameObject.Instantiate(RailPierceParticles, this.transform.position, Quaternion.LookRotation(-new Vector3(vec.x, vec.y, 0f))); GameObject.Destroy(p.gameObject, 1f); } else { ParticleSystem p = GameObject.Instantiate(DamageImpact, this.transform.position, Quaternion.LookRotation(-new Vector3(vec.x, vec.y, 0f))); GameObject.Destroy(p.gameObject, 1f); Remove(); } return; } IceBlock ib = col.GetComponentInParent <IceBlock>(); if (ib != null) { //be.TakeDamage(Damage, vec * 1f);//Damage ParticleSystem p = GameObject.Instantiate(DamageImpact, this.transform.position, Quaternion.LookRotation(-new Vector3(vec.x, vec.y, 0f))); ib.Remove(); if (RailSlug) { } else { GameObject.Destroy(p.gameObject, 1f); Remove(); } return; } BossGolem bo = col.GetComponent <BossGolem>(); bool weakspot = false; BossWeakSpot bwsp = col.GetComponent <BossWeakSpot>(); if (bwsp != null) { bo = bwsp.MyBossGolem; weakspot = true; } if (bo != null) { if (col.Equals(bo.MyWeakSpot)) { weakspot = true; } float dmg = Damage; if (weakspot) { float di = (dmg * 2f); if (di >= 1f) { bo.CriticalHitEffect.Emit(1); bo.CriticalHitEffectSub.Emit(1); bo.CriticalSparks.Emit((int)(20 * (dmg / 40f))); Astronaut.PlayBossCriticalHitSound(bo.Health / bo.MaxHealth); Astronaut.TheAstronaut.tickHitMarker(dmg, (bo.Health / bo.MaxHealth) * (bo.Defeated ? 1f : 0f), bo.Defeated); } else { bo.damagelayover = (bo.damagelayover + di); if ((bo.damagelayover) >= 1f) { bo.damagelayover -= 1f; bo.CriticalHitEffect.Emit(1); bo.CriticalHitEffectSub.Emit(1); bo.CriticalSparks.Emit(20); Astronaut.PlayBossCriticalHitSound(bo.Health / bo.MaxHealth); Astronaut.TheAstronaut.tickHitMarker(dmg, (bo.Health / bo.MaxHealth) * (bo.Defeated ? 1f : 0f), bo.Defeated); } } bo.TakeDamage(di, vec * 1f);//Damage } else { bo.TakeDamage(dmg, vec * 1f);//Damage } //Astronaut.TheAstronaut.tickHitMarker(Damage, (bo.Health / bo.MaxHealth) * (bo.Defeated ? 0f : 1f), bo.Defeated); weakspot = false; if (RailSlug) { } else { ParticleSystem p = GameObject.Instantiate(DamageImpact, this.transform.position, Quaternion.LookRotation(-new Vector3(vec.x, vec.y, 0f))); GameObject.Destroy(p.gameObject, 1f); Remove(); } return; } BreakableIceWall be = col.GetComponent <BreakableIceWall>(); if (be != null) { be.TakeDamage(Damage, vec * 1f);//Damage Astronaut.TheAstronaut.tickHitMarker(Damage, (be.Health / be.MaxHealth) * (be.Alive ? 1f : 0f), !be.Alive); if (RailSlug) { } else { ParticleSystem p = GameObject.Instantiate(DamageImpact, this.transform.position, Quaternion.LookRotation(-new Vector3(vec.x, vec.y, 0f))); GameObject.Destroy(p.gameObject, 1f); Remove(); } return; } if (col.gameObject.CompareTag("Water")) { //Splash MyRigidbody.velocity = (MyRigidbody.velocity * .5f); Damage *= .5f; return; } ParticleSystem ps = GameObject.Instantiate(GeometryImpact, this.transform.position, Quaternion.LookRotation(-new Vector3(vec.x, vec.y, 0f))); GameObject.Destroy(ps.gameObject, 1f); //Collision with geometry Remove(); }
public void Setup() { this.spaceship = new Spaceship(NAME, CAPACITY); this.astronaut = new Astronaut("Mitko", 10); }
void Start() { _astronautScript = astronaut.GetComponent <Astronaut>(); }
void Update() { Astronaut plr = Astronaut.TheAstronaut; float thr = .25f; if (((plr != null) && (plr.Alive))) { //Draw the weapon swap hud // SwapGroup.SetActive(false); //not now//YES NOW. I took care of it Color swpcol = Color.white; float re = 1f + (2f * (1f - (((Time.time - plr.NewWeaponAcquiredTime) % .5f) / .5f))); Vector3 selpos = SelectedCircle.transform.position; for (int i = 0; i < 7; i++) { float arcammo = 0f; if (i == 0) { //Pistol //SwapWeaponImages arcammo = (float)plr.PistolAmmo / Astronaut.MAXPISTOLAMMO; if (plr.CurrentSpecialWeapon == Astronaut.SpecialWeapon.Pistol) { selpos = SwapWeaponMainArcs[i].transform.position; } } else if (i == 1) { //Shotgun arcammo = (float)plr.ShotgunAmmo / Astronaut.SHOTGUNAMMOINCREMENT; if (plr.CurrentSpecialWeapon == Astronaut.SpecialWeapon.Shotgun) { selpos = SwapWeaponMainArcs[i].transform.position; } if ((plr.NewWeaponThatWasAcquired == Astronaut.SpecialWeapon.Shotgun) && ((Time.time - plr.NewWeaponAcquiredTime) <= 2f)) { SwapWeaponNewWepArc[i].enabled = true; SwapWeaponNewWepArc[i].transform.localScale = Vector3.one * re; } else { SwapWeaponNewWepArc[i].enabled = false; } } else if (i == 2) { //Machine Gun arcammo = (float)plr.GatlingAmmo / Astronaut.MACHINEGUNAMMOINCREMENT; if (plr.CurrentSpecialWeapon == Astronaut.SpecialWeapon.Gatling) { selpos = SwapWeaponMainArcs[i].transform.position; } if ((plr.NewWeaponThatWasAcquired == Astronaut.SpecialWeapon.Gatling) && ((Time.time - plr.NewWeaponAcquiredTime) <= 2f)) { SwapWeaponNewWepArc[i].enabled = true; SwapWeaponNewWepArc[i].transform.localScale = Vector3.one * re; } else { SwapWeaponNewWepArc[i].enabled = false; } } else if (i == 3) { //Laser Rifle arcammo = (float)plr.LaserAmmo / Astronaut.LASERGUNAMMOINCREMENT; if (plr.CurrentSpecialWeapon == Astronaut.SpecialWeapon.Laser) { selpos = SwapWeaponMainArcs[i].transform.position; } if ((plr.NewWeaponThatWasAcquired == Astronaut.SpecialWeapon.Laser) && ((Time.time - plr.NewWeaponAcquiredTime) <= 2f)) { SwapWeaponNewWepArc[i].enabled = true; SwapWeaponNewWepArc[i].transform.localScale = Vector3.one * re; } else { SwapWeaponNewWepArc[i].enabled = false; } } else if (i == 4) { //GrenadeLauncher arcammo = (float)plr.GrenadeLauncherAmmo / Astronaut.GRENADELAUNCHERAMMOINCREMENT; if (plr.CurrentSpecialWeapon == Astronaut.SpecialWeapon.GrenadeLauncher) { selpos = SwapWeaponMainArcs[i].transform.position; } if ((plr.NewWeaponThatWasAcquired == Astronaut.SpecialWeapon.GrenadeLauncher) && ((Time.time - plr.NewWeaponAcquiredTime) <= 2f)) { SwapWeaponNewWepArc[i].enabled = true; SwapWeaponNewWepArc[i].transform.localScale = Vector3.one * re; } else { SwapWeaponNewWepArc[i].enabled = false; } } else if (i == 5) { //TeslaGun arcammo = (float)plr.TeslaAmmo / Astronaut.TESLAGUNAMMOINCREMENT; if (plr.CurrentSpecialWeapon == Astronaut.SpecialWeapon.TeslaGun) { selpos = SwapWeaponMainArcs[i].transform.position; } if ((plr.NewWeaponThatWasAcquired == Astronaut.SpecialWeapon.TeslaGun) && ((Time.time - plr.NewWeaponAcquiredTime) <= 2f)) { SwapWeaponNewWepArc[i].enabled = true; SwapWeaponNewWepArc[i].transform.localScale = Vector3.one * re; } else { SwapWeaponNewWepArc[i].enabled = false; } } else if (i == 6) { //Railgun arcammo = (float)plr.RailGunAmmo / Astronaut.RAILGUNAMMOINCREMENT; if (plr.CurrentSpecialWeapon == Astronaut.SpecialWeapon.RailGun) { selpos = SwapWeaponMainArcs[i].transform.position; } if ((plr.NewWeaponThatWasAcquired == Astronaut.SpecialWeapon.RailGun) && ((Time.time - plr.NewWeaponAcquiredTime) <= 2f)) { SwapWeaponNewWepArc[i].enabled = true; SwapWeaponNewWepArc[i].transform.localScale = Vector3.one * re; } else { SwapWeaponNewWepArc[i].enabled = false; } } if ((arcammo <= 0f) && (i != 0)) { SwapWeaponMainArcs[i].enabled = false; SwapWeaponSubArcs[i].enabled = false; SwapWeaponImages[i].color = new Color(.8f, .8f, .8f, .4f); } else if (arcammo <= thr) { SwapWeaponMainArcs[i].enabled = true; SwapWeaponSubArcs[i].enabled = true; swpcol = Color.Lerp(new Color(1f, 0f, 0f, 1f), new Color(1f, 1f, 1f, 1f), .5f + (Mathf.Sin((Time.time / .3f) * Mathf.PI) * .5f)); SwapWeaponImages[i].color = swpcol; SwapWeaponMainArcs[i].fillAmount = (arcammo / thr); SwapWeaponSubArcs[i].color = new Color(.5f, .0f, .0f, .3f); } else if (arcammo < .5f) { SwapWeaponMainArcs[i].enabled = true; SwapWeaponSubArcs[i].enabled = true; swpcol = new Color(1f, .5f, 0f); SwapWeaponImages[i].color = Color.white; SwapWeaponMainArcs[i].fillAmount = arcammo; SwapWeaponSubArcs[i].color = new Color(.5f, .5f, .5f, .3f); } else { SwapWeaponMainArcs[i].enabled = true; SwapWeaponSubArcs[i].enabled = true; swpcol = new Color(1f, 1f, .5f); if (arcammo <= 1f) { SwapWeaponMainArcs[i].color = swpcol; SwapWeaponMainArcs[i].fillAmount = arcammo; SwapWeaponSubArcs[i].color = new Color(.5f, .5f, .5f, .3f); } else { SwapWeaponMainArcs[i].color = swpcol; SwapWeaponMainArcs[i].fillAmount = (arcammo % 1f); SwapWeaponSubArcs[i].color = (swpcol * (1f - (.25f * ((int)arcammo)))); } } } SelectedCircle.transform.position = Vector3.Lerp(SelectedCircle.transform.position, selpos, .25f); if (plr.SwappingWeapons || ((Time.time - plr.NewWeaponAcquiredTime) < 2f)) { if (SwapGroupScale < 1f) { //Play a sound } SwapGroupScale = 1f; if (plr.SwappingWeapons) { plr.NewWeaponAcquiredTime = -10f; } } else { if (SwapGroupScale < .01f) { SwapGroupScale = 0f; } else { SwapGroupScale = (SwapGroupScale * .8f);//SwapGroupScale = Mathf.Lerp(SwapGroupScale, 0f, Mathf.Clamp01(Time.deltaTime * 8f)); //Mathf.Clamp01(Time.time - plr.SwapWeaponViewTime) } } //Debug.Log(SwapGroupScale); SwapGroup.transform.localScale = (Vector3.one * BaseSwapGroupScale * SwapGroupScale); //SwapGroup.SetActive(SwapGroupScale > .01f); } if ((plr != null) && (plr.Alive) && (plr.PlayerHasControl) && (!plr.EtherealLock)) { TotalGroup.SetActive(true); } else { TotalGroup.SetActive(false); } if ((plr != null) && (plr.Alive) && (plr.PlayerHasControl) && (!plr.EtherealLock) && (!plr.SwappingWeapons)) { //plr.LastGunHUDAlertTime = ; Sprite spr = PistolFlatSprite; float ammovalue = 0f; Color wepcol = Color.white; string ammotext = ""; string weaponname = ""; if (plr.CurrentSpecialWeapon == Astronaut.SpecialWeapon.Pistol) { spr = PistolFlatSprite; ammovalue = (float)plr.PistolAmmo / Astronaut.MAXPISTOLAMMO; wepcol = Color.yellow; ammotext = "" + plr.PistolAmmo; weaponname = "PISTOL"; } else if (plr.CurrentSpecialWeapon == Astronaut.SpecialWeapon.Shotgun) { spr = ShotgunFlatSprite; ammovalue = (float)plr.ShotgunAmmo / Astronaut.SHOTGUNAMMOINCREMENT; wepcol = Color.yellow; ammotext = "" + plr.ShotgunAmmo; weaponname = "SHOTGUN"; } else if (plr.CurrentSpecialWeapon == Astronaut.SpecialWeapon.Gatling) { spr = MachineGunFlatSprite; ammovalue = (float)plr.GatlingAmmo / Astronaut.MACHINEGUNAMMOINCREMENT; wepcol = Color.yellow; ammotext = "" + plr.GatlingAmmo; weaponname = "MACHINEGUN"; } else if (plr.CurrentSpecialWeapon == Astronaut.SpecialWeapon.Laser) { spr = LaserBeamFlatSprite; ammovalue = plr.LaserAmmo / Astronaut.LASERGUNAMMOINCREMENT; wepcol = Color.yellow; ammotext = "" + (int)plr.LaserAmmo + "%"; weaponname = "LASER RIFLE"; } else if (plr.CurrentSpecialWeapon == Astronaut.SpecialWeapon.GrenadeLauncher) { spr = GrenadeLauncherFlatSprite; ammovalue = (float)plr.GrenadeLauncherAmmo / Astronaut.GRENADELAUNCHERAMMOINCREMENT; wepcol = Color.yellow; ammotext = "" + plr.GrenadeLauncherAmmo; weaponname = "GRENADE LAUNCHER"; } else if (plr.CurrentSpecialWeapon == Astronaut.SpecialWeapon.TeslaGun) { spr = TeslaCannonFlatSprite; ammovalue = plr.TeslaAmmo / Astronaut.TESLAGUNAMMOINCREMENT; wepcol = new Color(0.6f, 0.6f, 1f); ammotext = "" + (int)plr.TeslaAmmo + "%"; weaponname = "TESLA GUN"; } else if (plr.CurrentSpecialWeapon == Astronaut.SpecialWeapon.RailGun) { spr = RailGunFlatSprite; ammovalue = (float)plr.RailGunAmmo / Astronaut.RAILGUNAMMOINCREMENT; wepcol = Color.yellow; ammotext = "" + plr.RailGunAmmo + ""; weaponname = "RAIL GUN"; } CurrentWeaponEmptySpace.sprite = spr; CurrentWeaponImage.sprite = spr; CurrentWeapon2StockImage.sprite = spr; CurrentWeapon3StockImage.sprite = spr; CurrentWeapon4StockImage.sprite = spr; CurrentWeapon4StockImage.enabled = (ammovalue > 3f); CurrentWeapon4StockImage.color = wepcol * .25f; CurrentWeapon3StockImage.enabled = (ammovalue > 2f); CurrentWeapon3StockImage.color = wepcol * .5f; CurrentWeapon2StockImage.enabled = (ammovalue > 1f); CurrentWeapon2StockImage.color = wepcol * .75f; float alpha = .8f; if (ammovalue <= thr) { wepcol = Color.Lerp(new Color(1f, 0f, 0f, alpha), new Color(1f, 1f, 1f, alpha), .5f + (Mathf.Sin((Time.time / .3f) * Mathf.PI) * .5f)); CurrentWeaponImage.color = wepcol; CurrentWeaponEmptySpace.color = Color.Lerp(new Color(1f, 0f, 0f, alpha * .4f), new Color(.5f, .5f, .5f, alpha * .4f), .5f + (Mathf.Cos((Time.time / .3f) * Mathf.PI) * .5f)); CurrentWeaponEmptySpace.enabled = true; CurrentWeaponImage.fillAmount = (ammovalue / thr); } else if (ammovalue < .5f) { wepcol = new Color(1f, .5f, 0f); CurrentWeaponImage.fillAmount = ammovalue; CurrentWeaponImage.color = wepcol; CurrentWeaponEmptySpace.enabled = true; CurrentWeaponEmptySpace.color = new Color(.5f, .5f, .5f, .5f); } else { CurrentWeaponImage.color = wepcol; if (ammovalue <= 1f) { CurrentWeaponImage.fillAmount = ammovalue; CurrentWeaponEmptySpace.enabled = true; CurrentWeaponEmptySpace.color = new Color(.5f, .5f, .5f, .5f); } else { if ((ammovalue % 1f) == 0f) { CurrentWeaponImage.fillAmount = 1f; } else { CurrentWeaponImage.fillAmount = (ammovalue % 1f); } CurrentWeaponEmptySpace.enabled = true; CurrentWeaponEmptySpace.color = new Color(.5f, .5f, .5f, .15f); } } float sc = 1f + (1f * (1f - Mathf.Pow(Mathf.Clamp01((Time.time - Mathf.Max(plr.lastshottime, plr.lastpistolshottime)) / 2f), 1f / 3f))); CurrentWeaponImage.transform.localScale = Vector3.one * sc; CurrentWeaponEmptySpace.transform.localScale = Vector3.one * sc; AmmoGroup.SetActive(true); AmmoLabelString = ammotext; WeaponName = weaponname; if (plr.CurrentSpecialWeapon == Astronaut.SpecialWeapon.RailGun) { float rp = plr.RailGunCharge; if (plr.RailGunCharge > 0f) { if (rp < 1f) { RailGunChargeBar.color = Color.Lerp(new Color(1f, 1f, 1f, .75f), new Color(1f, 1f, .5f, .75f), rp); RailGunChargeBarGroup.transform.localScale = (Vector3.Lerp(RailGunChargeBarGroup.transform.localScale, Vector3.one, .1f)); } else { RailGunChargeBar.color = ((((rp - 1f) >= (3f / 5f)) && ((rp - 1f) % (1f / 8f)) < (1f / 16f))?Color.red:Color.Lerp(new Color(1f, 1f, 1f, .75f), new Color(1f, 1f, 0f, .75f), Mathf.Pow(Mathf.Sin(Mathf.PI * 2f * (rp - 1f) * 5f), 2f))); RailGunChargeBarGroup.transform.localScale = (Vector3.Lerp(Vector3.one * 1.5f, Vector3.one, rp - 1f)); } RailGunChargeBar.fillAmount = Mathf.Clamp01(plr.RailGunCharge); } else { RailGunChargeBar.color = Color.Lerp(RailGunChargeBar.color, new Color(RailGunChargeBar.color.r, RailGunChargeBar.color.g, RailGunChargeBar.color.b, 0f), .1f); RailGunChargeBarGroup.transform.localScale = (Vector3.Lerp(RailGunChargeBarGroup.transform.localScale, Vector3.one, .1f)); } RailGunChargeBarGroup.SetActive(true); } else { RailGunChargeBarGroup.SetActive(false); } } else { AmmoGroup.SetActive(false); } AmmoLabelText.text = AmmoLabelString; WeaponNameText.text = WeaponName; }
public void rm_astronaut(Astronaut astro) { if (l_astronaut.Contains(astro)) l_astronaut.Remove(astro); }
private void FixedUpdate() { Astronaut plr = Astronaut.TheAstronaut; if (Alive && !isStunned()) { if (Attacking) { if (ThrowingProjectile) { //Launch Projectile float tu = .3f; if (((Time.time - AttackingTime) >= tu) && (((Time.time - AttackingTime) - Time.fixedDeltaTime) < tu)) { aimdir = (Astronaut.TheAstronaut.transform.position - this.transform.position).normalized; ProjectileShotTime = Time.time; VoidSlashProjectile sl = GameObject.Instantiate <VoidSlashProjectile>(SlashProjectilePrefab, this.transform.position, SlashProjectilePrefab.transform.rotation); lastrangedattack = Time.time; Vector2 vf = (new Vector2(aimdir.x, aimdir.y).normalized *(10f * (1f + (1f * Astronaut.AggressionLevelF)))); sl.MyRigidbody.velocity = vf; /* * Vector2 r = Random.insideUnitCircle; * * sl = GameObject.Instantiate<VoidSlashProjectile>(sl, this.transform.position+new Vector3(r.x,r.y,0f), SlashProjectilePrefab.transform.rotation); * r = Random.insideUnitCircle; * * sl.MyRigidbody.velocity = (sl.MyRigidbody.velocity+new Vector2(r.x,r.y)* sl.MyRigidbody.velocity.magnitude*.25f* (Astronaut.AggressionLevelF)); */ SlashFlare.transform.position = this.transform.position + new Vector3(Mathf.Sign(aimdir.x), 0f, 0f); SlashFlare.Play(); Am.am.oneshot(Am.am.M.VoidPhantom_SlashLaunch); Debug.Log("SHOOT"); } if ((Time.time - AttackingTime) >= .8f) { Attacking = false; } } else { //Slash if (((Time.time - AttackingTime) >= .2f) && ((Time.time - AttackingTime) <= .4f)) { Collider2D col = Physics2D.OverlapCircle(new Vector2(this.transform.position.x + (.5f * Mathf.Sign(-this.transform.localScale.x)), this.transform.position.y), 1f, LayerMask.GetMask(new string[] { "Player" })); if (col != null) { Astronaut a = col.gameObject.GetComponent <Astronaut>(); if ((a != null) && (a.Alive) && (!slashhit)) { Vector3 dif = (plr.transform.position - this.transform.position); plr.TakeDamage(15f, -dif * 1f); SlashEffect.transform.position = a.transform.position; SlashEffect.Play(); Am.am.oneshot(Am.am.M.VoidPhantom_SlashHit); slashhit = true; } } if (!playedswing) { Am.am.oneshot(Am.am.M.VoidPhantom_SlashSwing); playedswing = true; } } if ((Time.time - AttackingTime) >= .5f) { Attacking = false; } } } else { if ((plr != null) && (plr.Alive) && (!Astronaut.TheAstronaut.Quelling)) { Vector3 dif = (plr.transform.position - this.transform.position); if (dif.magnitude < 10f) { if (dif.magnitude < 1.35f) { sliceAttack(); } else if (dif.magnitude < 8f) { MoveDirection = ((dif.normalized * ((dif.magnitude < 5f) ?6f:2f)) * (1f + (1f * Astronaut.AggressionLevelF))); if ((Time.time - lastrangedattack) >= (1.5f * (1f - Astronaut.AggressionLevelF))) { sliceProjectileAttack(); } } else { MoveDirection = ((dif.normalized * 3f) * (1f + (1f * Astronaut.AggressionLevelF))); } } else { MoveDirection = new Vector3(); } } } if (MoveDirection.x != 0f) { this.transform.localScale = new Vector3(Mathf.Abs(this.transform.localScale.x) * Mathf.Sign(-MoveDirection.x), this.transform.localScale.y, this.transform.localScale.z); } MyRigidbody.velocity = new Vector2(MoveDirection.x, MoveDirection.y) * (1f - FreezeFactor); } else { } }
//methodes public void add_astronaut(Astronaut astro) { l_astronaut.Add(astro); }
public virtual void AstronautEnter(Astronaut astronaut) { _astronauts.Add(astronaut); }
public void addAstronaut(Astronaut _astronaut) { l_astronaut.Add(_astronaut); }
public void Setup() { a = new Astronaut("A", 67); }