private void OnEnable() { //enemyCount = UnityEngine.Random.Range(1, 5); //I kind of want to tweak this so 4 happens more often or at least it 'feels' random enemyCount = 1; player.GetComponent <Player_Movement>().enabled = false; player.GetComponent <Rigidbody>().freezeRotation = true; alliesList = player.GetComponent <ListofAllies>().allies; foreach (GameObject obj in alliesList) { obj.GetComponent <Character>().CalculateStats(); } characterList.Add(player); SpawnEnemies(enemyCount); SpawnAllies(alliesList.Count); player.GetComponent <HeroStateMachine>().enabled = true; activeHeroCount++; foreach (GameObject obj in characterList) { obj.GetComponent <Character>().enabled = true; } turnCount = characterList.Count; //disable camera mouseAim script mainCamera.GetComponent <Mouse_Aim>().enabled = false; //calculate camera position for battle battleCameraPosition = player.transform.position + (0.5f * (player.transform.forward * enemyOffset)) - (player.transform.right * cameraHorizontalDistance); battleCameraPosition.y += cameraVerticalDistance; cameraTargetPosition = player.transform.position + (player.transform.forward * (0.5f * enemyOffset)) + (player.transform.right * (1.5f * characterSpacing)); cameraTargetPosition.y = 0; //enable corresponding camera script and move camera mainCamera.GetComponent <Camera_Battle>().enabled = true; mainCamera.GetComponent <Camera_Battle>().SetTargetPosition(cameraTargetPosition); mainCamera.GetComponent <Camera_Battle>().SetStandbyPosition(battleCameraPosition); battleCanvas.gameObject.SetActive(true); actionPanel.SetActive(false); enemySelectPanel.SetActive(false); victoryPanel.SetActive(false); defeatPanel.SetActive(false); initiativeBar.SetActive(true); heroPanel.SetActive(true); enemyPanel.SetActive(true); CharacterBars(); EnemyButtons(); ///FAIR WARNING I HAVE NO IDEA HOW THIS WORKS ///I STOLE IT FROM THE SECOND ANSWER ON THIS STACKEXCHANGE POST: https://stackoverflow.com/questions/3309188/how-to-sort-a-listt-by-a-property-in-the-object characterList.Sort((x, y) => y.GetComponent <Character>().Initiative.Value.CompareTo(x.GetComponent <Character>().Initiative.Value)); battleState = BattleState.CollectEnemyActions; heroInput = HeroInput.Wait; }
public void EnemySelection(GameObject target) { heroAction.target = target; target.transform.GetChild(0).gameObject.SetActive(false); enemySelectPanel.SetActive(false); heroInput = HeroInput.Done; }
public async Task <Hero> InsertAsync(HeroInput input) { var hero = new Hero(input.Name, new Editor(input.IdEditor), input.Age); if (!hero.IsValid()) { _notification.NewNotificationBadRequest("Os dados são obrigatórios"); return(default);
public async Task <IActionResult> Post([FromBody] HeroInput input) { var item = await _heroAppService .InsertAsync(input) .ConfigureAwait(false); return(CreatedContent("", item)); }
private void Start() { m_RigidBody = GetComponent <Rigidbody>(); m_Capsule = GetComponent <CapsuleCollider>(); mouseLook.Init(transform, cam.transform); moveCam = cam; heroInput = GetComponent <HeroBase>().GetInput(); }
public async Task <Hero> Insert(HeroInput input) { //TODO: Criar metodo de obter o editor pelo Id var hero = new Hero(input.Name, new Editor(input.IdEditor), input.Age); if (!hero.IsValid()) { _notification.NewNotificationBadRequest("Os dados não foram preenchidos corretamente!"); return(default);
private void Awake() { cachedAnimation = GetComponent <Animator>(); cachedBody = GetComponent <Rigidbody2D>(); cachedHands = GetComponent <HeroHands>(); cachedHero = GetComponent <HeroStats>(); cachedInput = GetComponent <HeroInput>(); cachedCollision = GetComponent <HeroCollisions>(); }
// private void Awake() { cachedVisuals = GetComponent <GameVisuals>(); cachedHero1Stats = hero1.GetComponent <HeroStats>(); cachedHero1Input = hero1.GetComponent <HeroInput>(); cachedHero2Stats = hero2.GetComponent <HeroStats>(); cachedHero2Input = hero2.GetComponent <HeroInput>(); }
public void Reset() { thirdPersonCamPosition = thirdPersonCam.transform.localPosition; thirdPersonCamRotation = thirdPersonCam.transform.localRotation; firstPerson = true; gameObject.layer = LayerMask.NameToLayer(team ? "Team1" : "Team2"); foreach (MonoBehaviour c in GetComponents <MonoBehaviour>()) { c.enabled = true; } body = GetComponent <Rigidbody>(); HeroInput[] inputs = GetComponents <HeroInput>(); camera = firstPersonCam; if (ai) { GetComponent <PlayerInput>().enabled = false; foreach (AudioListener al in GetComponentsInChildren <AudioListener>()) { al.enabled = false; } foreach (Camera cam in GetComponentsInChildren <Camera>()) { cam.enabled = false; } } else { GetComponent <AIInput>().enabled = false; } foreach (HeroInput i in inputs) { if (i.enabled) { input = i; } } if (ai) { Material[] theMaterials = new Material[2]; theMaterials[1] = heroMaterial; theMaterials[0] = new Material(outlineMaterial); theMaterials[0].SetColor("_OutlineColor", IsClientFriendly() ? Color.blue : Color.red); GetComponent <Renderer>().materials = theMaterials; } else { GetComponent <Renderer>().material = heroMaterial; camera = firstPersonCam; firstPersonCam.enabled = true; thirdPersonCam.enabled = false; } }
// private void Awake() { cachedHands = GetComponent <HeroHands>(); cachedInput = GetComponent <HeroInput>(); cachedCollision = GetComponent <HeroCollisions>(); cachedBody = GetComponent <Rigidbody2D>(); cachedTransform = GetComponent <Transform>(); stableRotation = Quaternion.LookRotation(Vector3.forward, Vector3.up); }
public void HeroInputDone() { heroAction.actor = heroesToManage[0]; heroesToManage[0].GetComponent <HeroStateMachine>().action = new ActionInfo(heroAction); heroesToManage[0].transform.GetChild(0).gameObject.SetActive(false); heroesToManage.RemoveAt(0); AddAction(heroAction); actionPanel.SetActive(false); heroInput = HeroInput.Active; }
void Awake() { input = new HeroInput(); random = new System.Random(); input.Player.Move.performed += ctx => OnMove(ctx); input.Player.Jump.performed += ctx => OnJump(ctx); input.Player.Attack.performed += ctx => OnAttack(ctx); input.Player.Block.performed += ctx => OnBlock(ctx); input.Player.Roll.performed += ctx => OnRoll(ctx); }
//-------------------------------------------------------------------------------- // EVENT CALLBACKS //-------------------------------------------------------------------------------- void Awake() { // EAGERLY ACQUIRE SINGLETON REFERENCE inst = this; // CACHE COMMON SIBLINGS input = GetComponent <HeroInput>(); fx = GetComponentInChildren <HeroFX>(); body = this.rigidbody; xform = this.transform; }
public IActionResult Post([FromBody] HeroInput input) { try { var item = _heroAppService.Insert(input); return(Created("", item)); } catch (ArgumentException ex) { return(BadRequest($"Erro => {ex.Message}")); } }
// Start is called before the first frame update void Awake() { health = GetComponent <Health>(); collider2d = GetComponent <Collider2D>(); spriteRenderer = GetComponent <SpriteRenderer>(); animator = GetComponent <Animator>(); input = new HeroInput(); random = new System.Random(); input.Player.Move.performed += ctx => OnMove(ctx); input.Player.Jump.performed += ctx => OnJump(ctx); input.Player.Attack.performed += ctx => OnAttack(ctx); input.Player.Block.performed += ctx => OnBlock(ctx); input.Player.Roll.performed += ctx => OnRoll(ctx); }
void returnToCenter(HeroInput input) { if (locking && toAdd < 0.05f && toAdd > -0.05f) { locking = false; locked = false; return; } if (toAdd > 0) { toAdd -= 0.05f; } if (toAdd < 0) { toAdd += 0.05f; } }
// Update is called once per frame void Update() { // marker.transform.position = new Vector2 (transform.position.x, transform.position.y); HeroInput input = hero.GetComponent <HeroInput> (); if (input != null) { //returnToCenter (input); } if (locking || locked) { this.transform.position = new Vector3(hero.transform.position.x + toAdd, this.transform.position.y, this.transform.position.z); } if (input != null) { if (input.getSpeedX() > 0) { if (toAdd > -gravyZoneWidth) { this.locking = true; this.locked = false; toAdd -= input.getSpeedX(); } else { this.locking = false; this.locked = true; } } if (input.getSpeedX() < 0) { if (toAdd < gravyZoneWidth) { this.locking = true; this.locked = false; toAdd -= input.getSpeedX(); } else { this.locking = false; this.locked = true; } } } }
public void Grab() { if (detectedObject == null) { return; } if (grabbedObject) { return; } if (grabbedJoint) { return; } grabbedObject = detectedObject; HeroInput grabbedInput = grabbedObject.GetComponent <HeroInput>(); if (grabbedInput && grabbedInput.IsBlocking()) { grabbedObject = null; return; } JamSuite.Physics2D.IgnoreCollision(grabbedObject.gameObject, cachedBody.gameObject, true); grabbedObject.transform.position = cachedTransform.position + Vector3.up * grabOffset; grabbedObject.gameObject.BroadcastMessage("PrepareForGrab", SendMessageOptions.DontRequireReceiver); grabbedMass = grabbedObject.mass; grabbedObject.mass = grabMass; grabbedJoint = gameObject.AddComponent <HingeJoint2D>(); grabbedJoint.anchor = new Vector2(0.0f, grabOffset); grabbedJoint.connectedBody = grabbedObject; grabbedJoint.useLimits = true; grabbedJoint.limits = new JointAngleLimits2D() { min = 0.0f, max = 0.0f }; }
public async Task Validar_Metodo_Insert_Sem_Dados_Obrigatorios(string name, int idEditor, int age) { //Arrange var input = new HeroInput(); input.Name = name; input.IdEditor = idEditor; input.Age = age; //Act var result = await this.heroAppService .InsertAsync(input) .ConfigureAwait(false); //Assert result .Should() .Be(default(Hero)); domainNotificationHandler .GetNotifications() .Should() .HaveCount(1); domainNotificationHandler .GetNotifications() .FirstOrDefault() .DomainNotificationType .Should() .Be(DomainNotificationType.BadRequest); domainNotificationHandler .GetNotifications() .FirstOrDefault() .Value .Should() .Be("Os dados são obrigatórios"); }
public async Task Validar_Metodo_Insert_Sem_Dados_Obrigatorios() { // Arrange var input = new HeroInput(); // Act var result = await this .heroAppService .Insert(input) .ConfigureAwait(false); // Assert result .Should() .Be(default(Hero)); domainNotificationHandler .GetNotifications() .Should() .HaveCount(1); domainNotificationHandler .GetNotifications() .FirstOrDefault() .DomainNotificationType .Should() .Be(DomainNotificationType.BadRequest); domainNotificationHandler .GetNotifications() .FirstOrDefault() .Value .Should() .Be("Os dados não foram preenchidos corretamente!"); }
public void LookRotation(Transform character, Transform camera, HeroInput input) { if (!input.mousePosIsFinal) { float yRot = input.GetMouseX() * XSensitivity; float xRot = input.GetMouseY() * YSensitivity; m_CharacterTargetRot *= Quaternion.Euler(0f, yRot, 0f); m_CameraTargetRot *= Quaternion.Euler(-xRot, 0f, 0f); } else { m_CharacterTargetRot = Quaternion.Euler(0f, input.GetMouseY(), 0f); m_CameraTargetRot = Quaternion.Euler(-input.GetMouseX(), 0f, 0f); } if (clampVerticalRotation) { m_CameraTargetRot = ClampRotationAroundXAxis(m_CameraTargetRot); } if (smooth) { character.localRotation = Quaternion.Slerp(character.localRotation, m_CharacterTargetRot, smoothTime * Time.deltaTime); camera.localRotation = Quaternion.Slerp(camera.localRotation, m_CameraTargetRot, smoothTime * Time.deltaTime); } else { character.localRotation = m_CharacterTargetRot; camera.localRotation = m_CameraTargetRot; } UpdateCursorLock(); }
// Update is called once per frame void Update() { switch (battleState) { case BattleState.CollectEnemyActions: foreach (GameObject obj in characterList) { if (obj.GetComponent <EnemyStateMachine>() != null && !obj.GetComponent <Character>().isDead) { obj.GetComponent <EnemyStateMachine>().currentState = EnemyStateMachine.State.Thinking; } if (obj.GetComponent <HeroStateMachine>() != null && !obj.GetComponent <Character>().isDead) { heroesToManage.Add(obj); } } battleState = BattleState.Wait; heroInput = HeroInput.Active; break; case BattleState.Wait: if (heroesToManage.Count == 0) { battleState = BattleState.ExecuteActions; } break; case BattleState.ExecuteActions: if (turnCount == 0) { battleState = BattleState.AssessBattleCondition; break; } if (characterList[0].GetComponent <EnemyStateMachine>() != null) { characterList[0].GetComponent <EnemyStateMachine>().currentState = EnemyStateMachine.State.Acting; } if (characterList[0].GetComponent <HeroStateMachine>() != null) { characterList[0].GetComponent <HeroStateMachine>().currentState = HeroStateMachine.State.Acting; } break; case BattleState.AssessBattleCondition: if (activeEnemyCount <= 0) { heroPanel.SetActive(false); enemyPanel.SetActive(false); initiativeBar.SetActive(false); actionPanel.SetActive(false); enemySelectPanel.SetActive(false); int totalExp = 0; foreach (GameObject obj in deadCharacters) { if (obj.GetComponent <EnemyStateMachine>() != null) { totalExp += obj.GetComponent <Character>().expIfDefeated; totalExp += UnityEngine.Random.Range(5 * obj.GetComponent <Character>().Level, (100 * obj.GetComponent <Character>().Level) + 1); } } battleState = BattleState.EndOfBattle; DisplayExperience(totalExp); DisplayItems(); victoryPanel.SetActive(true); break; } else if (activeHeroCount <= 0) { heroPanel.SetActive(false); enemyPanel.SetActive(false); initiativeBar.SetActive(false); actionPanel.SetActive(false); enemySelectPanel.SetActive(false); defeatPanel.SetActive(true); battleState = BattleState.EndOfBattle; break; } else { foreach (GameObject obj in characterList) { obj.GetComponent <Character>().isDefending = false; obj.transform.GetChild(1).gameObject.SetActive(false); } turnCount = characterList.Count; battleState = BattleState.CollectEnemyActions; break; } case BattleState.EndOfBattle: break; default: Debug.LogError("Battle State Error"); break; } switch (heroInput) { case HeroInput.Active: if (heroesToManage.Count > 0) { //heroAction = new ActionInfo(); actionPanel.SetActive(true); CheckEnemyButtons(); heroesToManage[0].transform.GetChild(0).gameObject.SetActive(true); heroInput = HeroInput.Wait; } break; case HeroInput.Wait: break; case HeroInput.Done: HeroInputDone(); break; default: Debug.LogError("Hero Input State Error"); break; } }
void Awake() { input = new HeroInput(); }
//-------------------------------------------------------------------------------- // EVENT CALLBACKS //-------------------------------------------------------------------------------- void Awake() { // EAGERLY ACQUIRE SINGLETON REFERENCE inst = this; // CACHE COMMON SIBLINGS input = GetComponent<HeroInput>(); fx = GetComponentInChildren<HeroFX>(); body = this.rigidbody; xform = this.transform; }
// private void Awake() { cachedRenderer = GetComponent <SpriteRenderer>(); cachedInput = GetComponent <HeroInput>(); }
public void DefendAction() { heroAction.actionType = ActionInfo.ActionType.Defend; heroInput = HeroInput.Done; }