void Start() { shooter = FindObjectOfType <ShooterController>(); anim = GetComponent <Animator>(); rbs = GetComponentsInChildren <Rigidbody>(); Ragdoll(false, transform); }
void Start() { body = GetComponent <Rigidbody2D>(); spriteRenderer_ = GetComponentInChildren <SpriteRenderer>(); animator_ = GetComponentInChildren <Animator>(); shooterController_ = GetComponentInChildren <ShooterController>(); }
// Use this for initialization void Start() { player = GameController.getMainPlayer(); state = STATE.Wait; shooter = GetComponent <ShooterController>(); seenHolder = GetComponent <SeenHolder>(); }
private ShooterChoice MakeRandomChoice(ShooterController shooter) { Debug.Log("Made random choice."); ShooterChoice choice = (ShooterChoice)Random.Range(1, 4); while (true) { // got shoot and have ammo if (choice == ShooterChoice.SHOOT && shooter.HasAmmo) { return(choice); } // got dodge and have energy if (choice == ShooterChoice.DODGE && shooter.HasEnergy) { return(choice); } if (choice == ShooterChoice.RELOAD) { return(choice); } choice++; if ((int)choice >= 4) { choice = (ShooterChoice)1; } } }
void Start() { shooterC = transform.root.GetComponentInChildren <ShooterController>(); //shooterC = transform.root.GetComponentInChildren<ProjectileAbility>(); m_myCharacterC = GetComponentInChildren <CharacterController>(); GRAVITY_CONSTANT /= 200; m_currentGravity = GRAVITY_CONSTANT; m_inputMove = Vector3.zero; m_input3rdAxis = 0F; m_move = Vector3.zero; m_timeStartJump = 0D; m_timeStartJumpWall = 0D; m_is3rdAxisInUseR = false; m_slideDirection = 1F; m_timeStartDashAccelerate = -1D; m_isDashing = false; m_currentNumDashes = 0; m_isLastTimeGrounded = false; swordA.Initialize(transform.root.gameObject); isWalking = false; isJumping = false; isDashing = false; JumpUp = false; myAnim.SetBool("isWalking", isWalking); myAnim.SetBool("isJumping", isJumping); myAnim.SetBool("isDashing", isDashing); myAnim.SetBool("JumpUp", JumpUp); }
private void ShootProjectile(GameObject Projectile) { GameObject projectileReference = Instantiate(Projectile, Weapon.transform.position, Weapon.transform.rotation); ShooterController gameCombatantController = Target.gameObject.GetComponent <ShooterController>(); projectileReference.SendMessage("SetTarget", gameCombatantController.HitZone, SendMessageOptions.RequireReceiver); projectileReference.SendMessage("SetSpeed", 20, SendMessageOptions.RequireReceiver); }
/// <summary> /// Start is called on the frame when a script is enabled just before /// any of the Update methods is called the first time. /// </summary> void Start() { Camera = Camera.main; Agent = GetComponent <UnityEngine.AI.NavMeshAgent>(); PlayerAnnimationController = GetComponent <PlayerAnnimationController>(); ShooterController = GetComponent <ShooterController>(); PlayerAnnimationController.SetAnimationCallbacks(this); }
public ShooterChoice Predict(ShooterController me, ShooterController enemy) { float[] input = new float[] { // player 1 (me) me.ammoCount, me.energyCount, me.health, // player 2 (other) enemy.ammoCount, enemy.energyCount, enemy.health }; float[] output = m_ann.Forward(input); int bestChoice = 0; float bestResult = output[0]; // find best for (int i = 1; i < output.Length; i++) { if (output[i] > bestResult) { bestChoice = i; bestResult = output[i]; } } // not sure enough. if (bestResult < 0.5f) { return(ShooterChoice.WAITING); } ShooterChoice choice = (ShooterChoice)(bestChoice + 1); // must have ammo to shoot if (choice == ShooterChoice.SHOOT && me.HasAmmo) { return(choice); } // got dodge and have energy if (choice == ShooterChoice.DODGE && me.HasEnergy) { return(choice); } if (choice == ShooterChoice.RELOAD) { return(choice); } return(ShooterChoice.WAITING); }
public override void OnInspectorGUI() { DrawDefaultInspector(); ShooterController script = (ShooterController)target; GUILayout.Space(10); if (GUILayout.Button("Kill")) { script.Kill(); } }
private ShooterChoice RBSChoice(bool asPlayerOne) { ShooterController me = asPlayerOne ? playerOne : playerTwo; ShooterController them = asPlayerOne ? playerTwo : playerOne; ShooterChoice choice = m_rbsController.GetChoice(me, them); if (choice == ShooterChoice.WAITING) { return(MakeRandomChoice(me)); } return(choice); }
private void Awake() { if (m_shooterController == null) { m_shooterController = GetComponent <ShooterController>(); } if (m_shooterController == null) { Debug.LogErrorFormat("Part in {0} requires Shooter Controller to be attached or set. Deactivating.", name); this.enabled = false; return; } }
public void InsertInList(Collider col) { if (col.CompareTag("EnemyUndead")) { UndeadController undead = col.GetComponent <UndeadController>(); undead.chasing = true; enemies.Add(col.gameObject); } else if (col.CompareTag("EnemyRange")) { ShooterController range = col.GetComponent <ShooterController>(); range.chasing = true; enemies.Add(col.gameObject); } }
// Use this for initialization void Start() { gameScript = GameObject.FindGameObjectWithTag("GameController").GetComponent <GameController>(); shooter = player.GetComponent <ShooterController>(); stalkers = new ArrayList(); GameObject[] lightemUps = GameObject.FindGameObjectsWithTag("LightEmUp"); foreach (GameObject stalker in lightemUps) { StalkerConroller stalkerController = stalker.GetComponent <StalkerConroller>(); if (stalkerController != null) { stalkers.Add(stalkerController); } } }
private static void LevelUp(LevelSettings settings) { ShooterController shooter = Instance.playerController.weapons[0] as ShooterController; shooter.firePower = settings.firePower; shooter.recoilTime = settings.recoilTime; shooter.recoilShake = settings.recoilShake; shooter.baseSettings = settings.weaponBaseSettings; shooter.fireOrigins = settings.fireOrigins; if (Instance._displayLevelUpCoroutine != null) { Instance.StopCoroutine(Instance._displayLevelUpCoroutine); } Instance.StartCoroutine(Instance.ExeDisplayChemoTreatmentCoroutine()); }
private ShooterChoice ANNChoice(bool asPlayerOne) { ShooterController me = asPlayerOne ? playerOne : playerTwo; ShooterController them = asPlayerOne ? playerTwo : playerOne; ShooterChoice choice = m_annController.Predict(me, them); if (choice == ShooterChoice.WAITING) { annText.text = "ANN: Not enough training. Using random choice."; return(MakeRandomChoice(me)); } annText.text = "ANN: Made a choice."; return(choice); }
void DesactivateChaseArea() { foreach (GameObject GO in enemies) { if (GO.CompareTag("EnemyUndead")) { UndeadController undead = GO.GetComponent <UndeadController>(); undead.chasing = false; } else if (GO.CompareTag("EnemyRange")) { ShooterController range = GO.GetComponent <ShooterController>(); range.chasing = false; } } enemies.Clear(); isCreated = false; }
public ShooterChoice GetChoice(ShooterController me, ShooterController enemy) { // convert to data Dictionary <string, int> data = new Dictionary <string, int>(); data.Add(DataNames.MY_AMMO.ToString().ToLower(), me.ammoCount); data.Add(DataNames.MY_ENERGY.ToString().ToLower(), me.energyCount); data.Add(DataNames.MY_HEALTH.ToString().ToLower(), me.health); data.Add(DataNames.ENEMY_AMMO.ToString().ToLower(), enemy.ammoCount); data.Add(DataNames.ENEMY_ENERGY.ToString().ToLower(), enemy.energyCount); data.Add(DataNames.ENEMY_HEALTH.ToString().ToLower(), enemy.health); // get results string output = m_rbs.Eval(data); // convert to enum // no rule applicable.. if (output == null) { return(ShooterChoice.WAITING); } if (output.Equals(ShooterChoice.SHOOT.ToString().ToLower())) { return(ShooterChoice.SHOOT); } if (output.Equals(ShooterChoice.DODGE.ToString().ToLower())) { return(ShooterChoice.DODGE); } if (output.Equals(ShooterChoice.RELOAD.ToString().ToLower())) { return(ShooterChoice.RELOAD); } Debug.Log("Rule system outputted an unknown value! " + output); return(ShooterChoice.WAITING); }
protected override void Update(uint dt) { ShooterController shooterController = Service.ShooterController; for (TrackingNode trackingNode = this.nodeList.Head; trackingNode != null; trackingNode = trackingNode.Next) { TrackingComponent trackingComp = trackingNode.TrackingComp; Entity turretTarget = shooterController.GetTurretTarget(trackingNode.ShooterComp); if (turretTarget != null && turretTarget != trackingComp.TargetEntity) { trackingComp.TargetEntity = turretTarget; trackingComp.Mode = TrackingMode.Entity; } if (trackingComp.Mode != TrackingMode.Disabled) { if (trackingComp.Mode == TrackingMode.Entity) { float num = (float)trackingNode.TrackingComp.TargetTransform.X - trackingNode.Transform.CenterX(); float num2 = (float)trackingNode.TrackingComp.TargetTransform.Z - trackingNode.Transform.CenterZ(); trackingComp.Yaw = Mathf.Atan2(num2, num); if (trackingNode.TrackingComp.TrackPitch) { float num3 = Mathf.Sqrt(num * num + num2 * num2); float num4 = Mathf.Sqrt(trackingNode.ShooterComp.MinAttackRangeSquared); float num5 = Mathf.Sqrt(trackingNode.ShooterComp.MaxAttackRangeSquared); num3 = Mathf.Clamp(num3, num4, num5); trackingComp.Pitch = 0.2617994f * (num5 - num3) / (num5 - num4); } } else if (trackingComp.Mode == TrackingMode.Location) { float x = (float)trackingComp.TargetX - trackingNode.Transform.CenterX(); float y = (float)trackingComp.TargetZ - trackingNode.Transform.CenterZ(); trackingComp.Yaw = Mathf.Atan2(y, x); } else if (trackingComp.Mode == TrackingMode.Angle) { trackingComp.Yaw = trackingComp.TargetYaw; } } } }
private void UpdateController(ShooterController controller, ShooterChoice choice) { switch (choice) { case ShooterChoice.SHOOT: controller.SubtractAmmo(); break; case ShooterChoice.DODGE: controller.SubtractEnergy(); break; case ShooterChoice.RELOAD: controller.AddAmmo(); controller.AddEnergy(); break; } controller.RunAnimation(choice); }
private void Initialize(SmartEntity entity, ShooterComponent shooterComp, StateComponent stateComponent, TransformComponent transformComponent, HealthType healthType) { this.Entity = entity; this.shooterController = Service.Get <ShooterController>(); this.ShooterComp = shooterComp; this.StateComponent = stateComponent; this.TransformComponent = transformComponent; this.IdleState = new IdleState(this); this.TurnState = new TurnState(this); this.WarmupState = new WarmupState(this); this.PreFireState = new PreFireState(this); this.PostFireState = new PostFireState(this); this.CooldownState = new CooldownState(this); this.shooterController.Reload(shooterComp); base.SetLegalTransition <IdleState, TurnState>(); base.SetLegalTransition <IdleState, WarmupState>(); base.SetLegalTransition <TurnState, IdleState>(); base.SetLegalTransition <TurnState, WarmupState>(); base.SetLegalTransition <WarmupState, IdleState>(); base.SetLegalTransition <WarmupState, PreFireState>(); base.SetLegalTransition <PreFireState, IdleState>(); base.SetLegalTransition <PreFireState, PostFireState>(); base.SetLegalTransition <PostFireState, IdleState>(); base.SetLegalTransition <PostFireState, PreFireState>(); base.SetLegalTransition <PostFireState, CooldownState>(); base.SetLegalTransition <CooldownState, IdleState>(); base.SetLegalTransition <CooldownState, WarmupState>(); if (entity.TroopComp != null && entity.TroopComp.TroopType.Type == TroopType.Champion && entity.TeamComp.TeamType == TeamType.Defender) { entity.StateComp.CurState = EntityState.Disable; entity.StateComp.ForceUpdateAnimation = true; } this.SetState(this.IdleState); this.healthType = healthType; this.ownerTeam = this.Entity.TeamComp.TeamType; this.lastLookAtX = (this.lastLookAtZ = 0); this.shotIndex = 0; TroopComponent troopComp = this.Entity.TroopComp; BuildingComponent buildingComp = this.Entity.BuildingComp; if (troopComp != null) { this.gunSequences = troopComp.TroopShooterVO.Sequences; return; } if (buildingComp != null) { string uid = null; BuildingType type = buildingComp.BuildingType.Type; if (type != BuildingType.Turret) { if (type == BuildingType.Trap) { uid = this.Entity.TrapComp.Type.TurretTED.TurretUid; } } else { uid = buildingComp.BuildingType.TurretUid; } TurretTypeVO turretTypeVO = Service.Get <IDataController>().Get <TurretTypeVO>(uid); this.gunSequences = turretTypeVO.Sequences; return; } Service.Get <StaRTSLogger>().Error("Attaching AttackFMS to Unsupported Entity. No Troop, Building, or Trap Componenet found."); }
private void Awake() { Instance = this; }
public void givenAnApiConsumer() { var shooterControllerUnderTest = new ShooterController(); testContext.ShooterControllerUnderTest = shooterControllerUnderTest; }
// Use this for initialization void Start() { Agent = GetComponent <UnityEngine.AI.NavMeshAgent>(); ShooterController = GetComponent <ShooterController>(); }