// Use this for initialization public void Start () { PauseController = GameObject.Find("PauseCanvas").GetComponent<PauseController>(); _timeAffected = GetComponent<TimeAffected> (); _timeAffected.ShadowBlinkHandler += OnShadowBlink; _timeAffected.PassPauseController (PauseController); _layeredController = GetComponent<LayeredController> (); _targetable = gameObject.GetComponent<Targetable> (); _targetable.DeathEventHandler += OnDeath; _camera = Camera.main.GetComponent<CameraController> (); _musicController = gameObject.GetComponent<MusicController> (); GetComponent<LayeredController> ().LayerChangedEventHandler += UpdateLayerTransparencyOnLayerChange; GetComponent<LayeredController> ().LayerChangedEventHandler += UpdateMusicOnLayerChange; _bigGearPrefab = (GameObject)Resources.Load ("BigGear"); _smallGearPrefab = (GameObject)Resources.Load ("SmallGear"); _bigGear = Instantiate (_bigGearPrefab).GetComponent<GearController> (); _bigGear.PassPauseController (PauseController); _smallGear = Instantiate (_smallGearPrefab).GetComponent<GearController> (); _smallGear.PassPauseController (PauseController); _bigGear.Player = this; _smallGear.Player = this; _bigGear.RotationSpeed = _bigGearDefaultRotationSpeed; _smallGear.RotationSpeed = _smallGearDefaultRotationSpeed; _bigGear.Damage = _bigGearDamage; _smallGear.Damage = _smallGearDamage; _layeredController.Initialize(); UpdateLayerTransparencyOnLayerChange(); SaveCheckpoint (); }
// Use this for initialization public void Start() { PauseController = GameObject.Find("PauseCanvas").GetComponent <PauseController>(); _timeAffected = GetComponent <TimeAffected> (); _timeAffected.ShadowBlinkHandler += OnShadowBlink; _timeAffected.PassPauseController(PauseController); _layeredController = GetComponent <LayeredController> (); _targetable = gameObject.GetComponent <Targetable> (); _targetable.DeathEventHandler += OnDeath; _camera = Camera.main.GetComponent <CameraController> (); _musicController = gameObject.GetComponent <MusicController> (); GetComponent <LayeredController> ().LayerChangedEventHandler += UpdateLayerTransparencyOnLayerChange; GetComponent <LayeredController> ().LayerChangedEventHandler += UpdateMusicOnLayerChange; _bigGearPrefab = (GameObject)Resources.Load("BigGear"); _smallGearPrefab = (GameObject)Resources.Load("SmallGear"); _bigGear = Instantiate(_bigGearPrefab).GetComponent <GearController> (); _bigGear.PassPauseController(PauseController); _smallGear = Instantiate(_smallGearPrefab).GetComponent <GearController> (); _smallGear.PassPauseController(PauseController); _bigGear.Player = this; _smallGear.Player = this; _bigGear.RotationSpeed = _bigGearDefaultRotationSpeed; _smallGear.RotationSpeed = _smallGearDefaultRotationSpeed; _bigGear.Damage = _bigGearDamage; _smallGear.Damage = _smallGearDamage; _layeredController.Initialize(); UpdateLayerTransparencyOnLayerChange(); SaveCheckpoint(); }
public virtual void Init() { IsActive = false; if (gearController == null) { gearController = transform.parent.GetComponent <GearController>(); } }
public async Task DeleteGear_CallWithAnIncorrectId_ShouldReturnNotFound() { var mockRepo = new Mock <IGearRepository>(); var controller = new GearController(mockRepo.Object); var result = await controller.DeleteGear(42); Assert.IsType <NotFoundResult>(result); }
public async Task GetGear_CallWithIdThatDoesntExist_ShouldReturnNotFound() { var mockRepo = new Mock <IGearRepository>(); var controller = new GearController(mockRepo.Object); var nonExistentGearId = 42; var result = await controller.GetGear(nonExistentGearId); Assert.IsType <NotFoundResult>(result.Result); }
public void ResetGearsInGame() { gearsInGame.Clear(); GearController[] gearsIG = FindObjectsOfType <GearController>(); foreach (GearController gear in gearsIG) { GearController initializedGead = InitializeGear(gear); gearsInGame.Add(initializedGead); } }
public void closeTest() { GearController gc = new GearController(); gc.ShouldDeploy = true; Gear gear = new Gear(gc); gear.Retract(); System.Threading.Thread.Sleep(15000); Assert.AreEqual(GearState.LOCKUP, gear.GearState); }
public void openTest() { GearController gc = new GearController(); gc.ShouldDeploy = true; Gear gear = new Gear(gc); gear.Deploy(); System.Threading.Thread.Sleep(15000); Assert.AreEqual(GearState.LOCKDOWN, gear.GearState); }
public async Task DeleteGear_CallWithIdAndGearDTO_ShouldReturnNoContent() { var mockRepo = new Mock <IGearRepository>(); mockRepo.Setup(repo => repo.GetByIdAsync(It.IsAny <long>()).Result) .Returns(MockGear()); var controller = new GearController(mockRepo.Object); var result = await controller.DeleteGear(1); Assert.IsType <NoContentResult>(result); }
void defineComponents() { planeAnimator = GetComponent <PlaneAnimator>(); planeRB = GetComponent <Rigidbody2D>(); hinge = GetComponent <HingeJoint2D>(); aerofoilList = gameObject.GetComponentsInChildren <Aerofoil>(); gearCtrl = gear.GetComponent <GearController>(); propellerMotor = propeller.GetComponent <PropellerMotor>(); flapJoint = flap.GetComponent <HingeJoint2D>(); flapMotor = new JointMotor2D(); hingemotor = new JointMotor2D(); }
public void Pickup(GearController controller) { if (permanentStock) { GameObject shopItem = Instantiate(gameObject, gameObject.transform.parent); shopItem.name = gameObject.name; } //TODO maybe switch WeaponScript out with more generic? idk controller.SwitchWeapon(GetComponent <WeaponScript>()); Destroy(this); }
private void Start() { _gearController = GameObject.FindGameObjectWithTag("GearController").GetComponent <GearController>(); _pivots = new List <GameObject>(); foreach (GameObject pivot in GameObject.FindGameObjectsWithTag("Pivot")) { _pivots.Add(pivot); } _playerSounds = GetComponent <PlayerSounds>(); }
void Start() { gearController = gearController ?? GetComponent <GearController>(); meshRenderer = meshRenderer ?? GetComponent <MeshRenderer>(); trailRenderer = trailRenderer ?? GetComponent <TrailRenderer>(); meshRenderer.material = defaultMat; trailRenderer.material = defaultMat; meshRenderer.enabled = true; trailRenderer.enabled = true; clrTempTransparent = clrOriginalTransparent; transparentMat.color = clrOriginalTransparent; }
//TODO: ontriggerenter or ontriggerstay (permanent or not) void OnTriggerStay(Collider collider) { GearController gc = collider.GetComponent <GearController>(); PlayerController player = collider.GetComponent <PlayerController>(); if ((GearActivates && gc && gc.isBeingThrown()) || (PlayerActivates && player)) { foreach (Triggerable t in Triggerables) { t.Trigger(); } } }
public async Task UpdateGear_CallWithIdThatDoesntExist_ShouldReturnNotFound() { var mockRepo = new Mock <IGearRepository>(); var controller = new GearController(mockRepo.Object); var gear = new GearDTO() { Id = 42, Name = "EditedGear", }; var result = await controller.UpdateGear(42, gear); Assert.IsType <NotFoundResult>(result); }
private void Awake() { rb = GetComponent <Rigidbody>(); ins = this; //serialize this //250 pullspeed for addforce //10 pullspeed for velo model = new GearModel(0.01f, 500f, 7f); rb.isKinematic = true; // pooler.Preload(Instantiate(hook, transform.position, Quaternion.Euler(Vector3.zero)) as GameObject, 4); pooler.Preload(hook, 4); tempLeft = left; tempRight = right; }
public void SpawnGear(string gear, Vector3 position) { GameObject newGearObject = Instantiate(Resources.Load(gear), position, Quaternion.Euler(new Vector3(-90, 0, 90))) as GameObject; newGearObject.transform.localScale = Vector3.one * 10; if (gear.Equals("Prefabs/Gears/HealingPotion")) { newGearObject.transform.localScale = new Vector3(0.2f, 0.2f, 0.2f); newGearObject.transform.rotation = Quaternion.Euler(Vector3.zero); } newGearObject.transform.SetParent(gearsInLevel.transform); GearController newGear = newGearObject.GetComponent <GearController>(); GearController intilializedGear = InitializeGear(newGear); gearsInGame.Add(intilializedGear); }
public async Task GetGear_CallWithAnIdThatExists_ShouldReturnCorrectGear() { var mockRepo = new Mock <IGearRepository>(); mockRepo.Setup(repo => repo.GetByIdAsync(It.IsAny <long>()).Result) .Returns(MockGear()); var controller = new GearController(mockRepo.Object); var result = await controller.GetGear(1); var gear = result.Value; Assert.IsType <GearDTO>(gear); Assert.Equal("Cam", gear.Name); }
public void ResetGearSlots(SlotsController slotsC) { foreach (Slot s in slotsC.slots) { if (s.slot.transform.childCount > 0) { GearController slotsGear = s.slot.transform.GetChild(0).GetComponent <GearController>(); if (slotsGear != null) { s.gear = slotsGear; s.slotEmpty = false; s.SetName(s.gear.name); s.gear.gameObject.SetActive(false); } else { Debug.Log("Child(0) of this slot is not a gear !"); s.slotEmpty = true; s.SetName("Empty Slot"); } } else { s.slotEmpty = true; s.SetName("Empty Slot"); } } slotsC.slotIndex = 0; slotsC.activeSlot = slotsC.slots[slotsC.slotIndex]; if (slotsC.activeSlot.slot.transform.childCount > 0 && !slotsC.activeSlot.slotEmpty) { slotsC.activeSlot.gear.gameObject.SetActive(true); slotsC.activeSlot.gear.enabled = true; if (slotsC.activeSlot.gear.gearType == GearType.Weapon) { slotsC.activeWeapon = slotsC.activeSlot.gear as Weapon; slotsC.activeConsumable = null; slotsC.ApplyArsenalToGear(); } else if (slotsC.activeSlot.gear.gearType == GearType.Consumable) { slotsC.activeConsumable = slotsC.activeSlot.gear as Consumable; slotsC.activeWeapon = null; } ActivateHudGear(slotsC.activeSlot.gear); } }
public async Task CreateGear_CallWithNewGearDTO_ShouldReturnNewGearAndCreated() { var mockRepo = new Mock <IGearRepository>(); var controller = new GearController(mockRepo.Object); var gear = new GearDTO() { Name = "NewGear", }; var result = await controller.CreateGear(gear); var resultObject = result.Result as CreatedAtActionResult; var resultGear = resultObject.Value as GearDTO; Assert.Equal(201, resultObject.StatusCode); Assert.Equal(gear.Name, resultGear.Name); }
public void ActivateHudGear(GearController gear) { if (gear.gearType == GearType.Weapon) { Weapon weapon = gear as Weapon; consumableHUD.SetActive(false); weaponHUD.SetActive(true); textMunitions.SetMyText(weapon.munitions.ToString()); textCapacity.SetMyText(weapon.capacity.ToString()); } else if (gear.gearType == GearType.Consumable) { Consumable consumable = gear as Consumable; weaponHUD.SetActive(false); consumableHUD.SetActive(true); textConsumablesRemaining.SetMyText(consumable.consumablesRemaining.ToString()); } }
public async Task UpdateGear_CallWithIdAndWrongGearId_ShouldReturnBadRequest() { var mockRepo = new Mock <IGearRepository>(); mockRepo.Setup(repo => repo.GetByIdAsync(It.IsAny <long>()).Result) .Returns(MockGear()); var controller = new GearController(mockRepo.Object); var gear = new GearDTO() { Id = 2, Name = "EditedGear", }; var result = await controller.UpdateGear(1, gear); Assert.IsType <BadRequestResult>(result); }
public void ClearGearsInGame() { for (int i = gearsInGame.Count - 1; i >= 0; i--) { Debug.Log("Gears to clear : " + gearsInGame.Count + " i : " + i); GearController gear = gearsInGame[i]; if (gear.gearType == GearType.Weapon) { Weapon weaponToDestroy = gear as Weapon; weaponToDestroy.SelfDestroyW(); } else if (gear.gearType == GearType.Consumable) { Consumable consumableToDestroy = gear as Consumable; consumableToDestroy.SelfDestroyC(); } } gearsInGame.Clear(); }
public async Task GetGear_CallGetGearWithNoId_ShouldReturnAllGear() { var mockList = MockDTOList(); var mockRepo = new Mock <IGearRepository>(); mockRepo.Setup(repo => repo.DTOListAsync().Result).Returns(mockList); var controller = new GearController(mockRepo.Object); var result = await controller.GetGear(); var gearList = new List <GearDTO>(result.Value); Assert.Equal(3, gearList.Count); Assert.Equal(mockList[0], gearList[0]); Assert.Equal(mockList[1], gearList[1]); Assert.Equal(mockList[2], gearList[2]); }
// Use this for initialization public void Start() { if (!isParent) return; GetComponent<LayeredController>().LayerChangedEventHandler += UpdateLayerTransparencyOnLayerChange; Initialize(); _bigGearPrefab = (GameObject) Resources.Load("BigGear"); _smallGearPrefab = (GameObject) Resources.Load("SmallGear"); _bigGear = Instantiate(_bigGearPrefab).GetComponent<GearController>(); _smallGear = Instantiate(_smallGearPrefab).GetComponent<GearController>(); _bigGear.Player = this; _smallGear.Player = this; _bigGear.RotationSpeed = _bigGearDefaultRotationSpeed; _smallGear.RotationSpeed = _smallGearDefaultRotationSpeed; _bigGear.Damage = _bigGearDamage; _smallGear.Damage = _smallGearDamage; }
// Use this for initialization public void Start() { if (!isParent) { return; } GetComponent <LayeredController>().LayerChangedEventHandler += UpdateLayerTransparencyOnLayerChange; Initialize(); _bigGearPrefab = (GameObject)Resources.Load("BigGear"); _smallGearPrefab = (GameObject)Resources.Load("SmallGear"); _bigGear = Instantiate(_bigGearPrefab).GetComponent <GearController>(); _smallGear = Instantiate(_smallGearPrefab).GetComponent <GearController>(); _bigGear.Player = this; _smallGear.Player = this; _bigGear.RotationSpeed = _bigGearDefaultRotationSpeed; _smallGear.RotationSpeed = _smallGearDefaultRotationSpeed; _bigGear.Damage = _bigGearDamage; _smallGear.Damage = _smallGearDamage; }
public void Pickup(GearController controller) { switch (powerupType) { case PowerupType.money: controller.GetComponent <MoneyController>().AddMoney(value); controller.GetComponent <AudioSource>().PlayOneShot(pickupSound); Destroy(gameObject); break; case PowerupType.key: if (!controller.GetComponent <MoneyController>().HasKey()) { controller.GetComponent <MoneyController>().SetKey(true); controller.GetComponent <AudioSource>().PlayOneShot(pickupSound); Destroy(gameObject); } break; case PowerupType.health: if (controller.GetComponent <HealthController>().currHealth < controller.GetComponent <HealthController>().maxHealth) { controller.GetComponent <HealthController>().Heal(value); controller.GetComponent <AudioSource>().PlayOneShot(pickupSound); Destroy(gameObject); } break; case PowerupType.ammo: //TODO move ShouldPickup to IAttackable and check that instance on the weapon as it is guaranteed to be on a weapon RangedAttack attack = controller.weapon.GetComponent <RangedAttack>(); if (attack != null && attack.ShouldPickup()) { attack.GetAmmo(attack.maxAmmo / 4); controller.GetComponent <AudioSource>().PlayOneShot(pickupSound); Destroy(gameObject); } break; } }
public GearController InitializeGear(GearController gearToInitialize) { gearToInitialize.me = gearToInitialize; gearToInitialize.fpsCam = playerCam; gearToInitialize.gameManager = me; gearToInitialize.audioManager = audioManager; gearToInitialize.slotsController = slotsController; gearToInitialize.ResetGear(); gearToInitialize.enabled = false; if (gearToInitialize.gearType == GearType.Weapon) { Weapon weaponToInitialize = gearToInitialize as Weapon; weaponToInitialize.name = weaponToInitialize.mType.ToString(); weaponToInitialize.targetsMask = groundMask | enemiesMask | npcMask; } if (gearToInitialize.gearType == GearType.Consumable) { Consumable consumableToInitialize = gearToInitialize as Consumable; consumableToInitialize.name = consumableToInitialize.mType.ToString(); consumableToInitialize.playerController = playerController; } return(gearToInitialize); }
public void LootGear(GearController gearToLoot, GearType gearType) { if (gearToLoot.gearType == GearType.Consumable) { Consumable consumableToLoot = gearToLoot as Consumable; foreach (Slot s in slots) { if (s.gear != null && s.gear.gearType == GearType.Consumable && s.gear.name == consumableToLoot.name) { Consumable updatedConsumable = s.gear as Consumable; updatedConsumable.consumablesRemaining += consumableToLoot.consumablesRemaining; consumableToLoot.SelfDestroyC(); if (s == activeSlot) { gameManager.ActivateHudGear(activeSlot.gear); } return; } } } Slot lootingSlot = null; if (activeSlot.slotEmpty) { lootingSlot = activeSlot; } foreach (Slot s in slots) { if (lootingSlot != null || !s.slotEmpty) { continue; } lootingSlot = s; } if (lootingSlot == null && !activeSlot.slotEmpty) { Debug.Log("Droping " + activeSlot.gear.name); DropWeapon(); lootingSlot = activeSlot; } gearToLoot.transform.parent = lootingSlot.slot.transform; lootingSlot.gear = gearToLoot; lootingSlot.gear.transform.position = lootingSlot.slot.transform.position; if (gearToLoot.name == "HealingPotion") { lootingSlot.gear.transform.rotation = Quaternion.Euler(Vector3.zero); } else { lootingSlot.gear.transform.rotation = lootingSlot.slot.transform.rotation; } lootingSlot.SetName(gearToLoot.name); lootingSlot.slotEmpty = false; if (lootingSlot == activeSlot) { lootingSlot.gear.gameObject.SetActive(true); lootingSlot.gear.gameObject.GetComponent <GearController>().enabled = true; if (gearToLoot.gearType == GearType.Weapon) { activeWeapon = gearToLoot as Weapon; activeConsumable = null; ApplyArsenalToGear(); } else if (gearToLoot.gearType == GearType.Consumable) { activeConsumable = gearToLoot as Consumable; activeWeapon = null; } gameManager.ActivateHudGear(lootingSlot.gear); } else { lootingSlot.gear.gameObject.SetActive(false); } }
void Start() { masterGearController = masterGear.GetComponent <GearController>(); }
private void Start() { _gearController = GameObject.FindGameObjectWithTag("GearController").GetComponent <GearController>(); _originalPosition = transform.position; }
// Start // Runs once the object is loaded in void Awake() { characterController = GetComponent <CharacterController>(); gearController = GetComponent <GearController>(); animator = GetComponent <Animator>(); }