public void DoIMove(BaseMovement movementToDo) { float distanceToTarget = Vector3.Distance(target.position, transform.position); if (movementToDo != null) { switch (movementToDo.movementType) { case BaseMovement.MovementType.goToTarget: goToTarget = true; runAway = false; standStill = false; break; case BaseMovement.MovementType.runAway: goToTarget = false; runAway = true; standStill = false; break; case BaseMovement.MovementType.standStill: goToTarget = false; runAway = false; standStill = true; break; } } }
public Enemy(int enemyId, Position position) : base(position) { EnemyId = enemyId; UniqueId = new Random().Next(0, 90000); BaseMovement = new RandomMovement(Position); }
void Start() { CurrFrameType = FrameType.Regular; movement = GetComponent <BaseMovement> (); hitBoxes = GetComponent <HitBoxes> (); currentHealth = totalHealth; try{ stageManager = FindObjectOfType <StageManager>(); if (teamNumber == 1) { lockOnTargets.AddRange(stageManager.team2); lockOnTarget = lockOnTargets [0]; } else if (teamNumber == 2) { lockOnTargets.AddRange(stageManager.team1); lockOnTarget = lockOnTargets [0]; } }catch { //lockOnTargets.Add (FindObjectsOfType<FighterClass>); foreach (FighterClass fighter in FindObjectsOfType <FighterClass>()) { if (fighter.teamNumber != teamNumber) { lockOnTargets.Add(fighter.gameObject); } } lockOnTarget = lockOnTargets [0]; } if (teamNumber == 2) { ToggleDirection(); } }
// Start is called before the first frame update protected override void Start() { base.Start(); baseMovement = GetComponent <BaseMovement>(); baseMovement.AddChildMovement(this); ResetGravityParams(); }
void Awake() { baseMovement = GetComponent <BaseMovement>(); baseMovement.movementDirection = Vector3.zero; playerAnimation = GetComponent <CharacterAnimation>(); }
void Start() { if (bearer == null) { bearer = transform.parent.parent.GetComponent <BaseMovement>(); } }
// The function to call when creating a clone to initialise everything public void Create(BaseMovement moveComponent, BaseCombat combatComponent, Vector3 startingPos, float activeTime, GameObject target, GameObject projectilePrefab) { // Initialise the target m_Target = target; // Add a navmesh agent m_Agent = (NavMeshAgent) gameObject.AddComponent (Constants.NAV_AGENT); // Create a move component of the same type as the one passed System.Type movementType = moveComponent.GetType (); string moveType = movementType.ToString (); m_MovementComponent = (BaseMovement) gameObject.AddComponent (moveType); // Set the agent of that move component if (m_MovementComponent != null) m_MovementComponent.SetAgent (m_Agent); //Create a combat component of the same type as the one passed System.Type combatType = combatComponent.GetType (); string comType = combatType.ToString (); m_CombatComponent = (BaseCombat) gameObject.AddComponent (comType); // Initialise the projectile prefab if (m_CombatComponent != null) m_CombatComponent.SetProjectilePrefab (projectilePrefab); // Set the active timer m_ActiveTimer = activeTime; // move to the starting attack position if (m_MovementComponent != null) m_MovementComponent.Movement (startingPos); m_Health = 0.5f; }
public void InitHandler(PlayerSide side, BaseMovement otherPlayer) { handler = Instantiate(handlerPrefab); handler.playerMcts = this; handler.opponent = otherPlayer; handler.side = side; handler.InitAwake(); }
protected override void Start() { base.Start(); Movement = new BaseMovement(MaxSpeed); animator = this.gameObject.GetComponent <Animator>(); magics = new MagicBox(this); }
protected void Init(Vector2 position, Vector2Int dir, BaseMovement baseMvt, InteractorSimulated interactor) { Position = position; Direction = dir; baseMovement = baseMvt; InteractorSimulated = interactor; InteractorSimulated.Position = position; }
protected override void Start() { base.Start(); LifeTimer = new LifeTimer(LifeTime); Movement = new BaseMovement(MaxSpeed); rigidbody.AddForce(Direction * Movement.CurrentSpeed, ForceMode.VelocityChange); }
public override void SetComponents(string[] components) { m_ComponentsObject = transform.FindChild (Constants.COMPONENTS_STRING).gameObject; m_CombatComponent = m_ComponentsObject.GetComponent (components [0]) as BaseCombat; m_TargetingComponent = m_ComponentsObject.GetComponent (components [1]) as BaseTargeting; m_MovementComponent = m_ComponentsObject.GetComponent (components [2]) as BaseMovement; }
protected override void Start() { base.Start(); Movement = new BaseMovement(MaxSpeed); animator = this.gameObject.GetComponent<Animator>(); magics = new MagicBox(this); }
public override void SetComponents(string[] components) { m_ComponentsObject = transform.FindChild(Constants.COMPONENTS_STRING).gameObject; m_CombatComponent = m_ComponentsObject.GetComponent(components [0]) as BaseCombat; m_TargetingComponent = m_ComponentsObject.GetComponent(components [1]) as BaseTargeting; m_MovementComponent = m_ComponentsObject.GetComponent(components [2]) as BaseMovement; }
public int CalculateMove(CharacterStats myStats, CharacterStats targetStats, float distanceToTarget) { if (myStats.damageDealt >= myStats.damageReceived) { foreach (BaseMovement m in availableMovementes) { if (m.movementType == BaseMovement.MovementType.standStill) { m.movementScore = 1f; } else { m.movementScore = 0f; } } } if (myStats.damageDealt == 0 || myStats.currentHealth >= targetStats.currentHealth && myStats.damageReceived > myStats.damageDealt) { foreach (BaseMovement m in availableMovementes) { if (m.movementType == BaseMovement.MovementType.goToTarget) { m.movementScore = 1f; } else { m.movementScore = 0f; } } } if (myStats.totalDamageDealt < myStats.totalDamageReceived || myStats.currentHealth < targetStats.currentHealth) { foreach (BaseMovement m in availableMovementes) { if (m.movementType == BaseMovement.MovementType.runAway) { m.movementScore = 1f; } else { m.movementScore = 0f; } } } foreach (BaseMovement m in availableMovementes) { if (selectedMovement == null) { selectedMovement = m; } else if (m.movementScore > selectedMovement.movementScore) { selectedMovement = m; } } return(selectedMovement.moveID); }
public override void M_StopOrder() { BaseMovement movement = GetComponentInChildren <BaseMovement>(); if (movement) { movement.M_StopOrder(); } }
// Start is called before the first frame update void Start() { bm = GetComponent <BaseMovement>(); anim = GetComponent <Animator>(); rb = GetComponent <Rigidbody2D>(); pfsg = 0; pushll = GetComponent <PushPull>(); canInput = true; }
private void OnValidate() { baseMovement = GetComponent <BaseMovement>(); baseControll = GetComponent <BaseControll>(); Debug.Assert(GetComponent <CircleCollider2D>().isTrigger == true); Debug.Assert(baseMovement != null); Debug.Assert(baseControll != null); }
private void Move(BaseMovement baseMovement) { switch (baseMovement.movementType) { case BaseMovement.MovementType.goToTarget: myAgent.stoppingDistance = 1f; myAgent.isStopped = myAgent.isStopped == true ? false : false; Vector3 lookDirection = (target.transform.position - transform.position).normalized; Quaternion lookRotation = Quaternion.LookRotation(new Vector3(lookDirection.x, 0f, lookDirection.z)); transform.rotation = Quaternion.Slerp(transform.rotation, lookRotation, Time.deltaTime * .5f); myAgent.SetDestination(target.transform.position); break; case BaseMovement.MovementType.runAway: if (myAgent.velocity.magnitude == 0 && lastTime - Time.time < 0) { switch (rotateTo) { case "left": transform.position = new Vector3(transform.position.x + .3f, transform.position.y, transform.position.z + .3f); break; case "right": transform.position = new Vector3(transform.position.x - .3f, transform.position.y, transform.position.z - .3f); break; } if (lastTime - Time.time < 0) { rotateTo = rotateTo == "right" ? "left" : "right"; lastTime = Time.time + 1f; } } else { myAgent.stoppingDistance = 0; myAgent.isStopped = myAgent.isStopped == true ? false : false; /*** LOOK AT PLAYER ALL THE TIME ***/ lookDirection = -1 * (transform.position - target.transform.position).normalized; lookRotation = Quaternion.LookRotation(new Vector3(lookDirection.x, 0f, lookDirection.z)); transform.rotation = Quaternion.Slerp(lookRotation, transform.rotation, Time.deltaTime * .5f); /***********************************/ Vector3 direction = (transform.position - target.transform.position).normalized; myAgent.SetDestination(transform.position + direction); } break; /* case BaseMovement.MovementType.standStill: * myAgent.isStopped = myAgent.isStopped == true ? false : false; * lookDirection = (target.transform.position - transform.position).normalized; * lookRotation = Quaternion.LookRotation(new Vector3(lookDirection.x, 0f, lookDirection.z)); * transform.rotation = Quaternion.Slerp(transform.rotation, lookRotation, Time.deltaTime * .5f); * myAgent.SetDestination(transform.position); * break;*/ } }
private void Awake() { // Set the duration of the effect CountDownTime = _effectDuration; // Call Init() after setting the CountDownTime Init(); GameClock.Instance.Ticked += CountDown; GameClock.Instance.Ticked += Lock; _baseMovement = GetComponent <BaseMovement>(); }
protected void onValidate() { //Debug.Log("BaseControll"); //attack = GetComponent<Attack>(); baseMovement = GetComponent <BaseMovement>(); health = GetComponent <Health>(); DetectDistance = GetComponent <CircleCollider2D>().radius; Debug.Assert(gameObject.tag != "Untagged", gameObject.name + " Don't set tag"); //Debug.Assert(attack != null, gameObject.name); Debug.Assert(health != null, gameObject.name); }
public void ResetStats() { currentHealth = maxHealth; currentStamina = maxStamina; damageReceived = 0; damageDealt = 0; totalDamageDealt = 0; totalDamageReceived = 0; lastAttackMade = null; lastMovementMade = null; health.value = maxHealth; stamina.value = maxStamina; }
public override void SetComponents(string[] components) { m_ComponentsObject = transform.FindChild(Constants.COMPONENTS_STRING).gameObject; m_CombatComponent = m_ComponentsObject.GetComponent(components [0]) as BaseCombat; m_TargetingComponent = m_ComponentsObject.GetComponent(components [1]) as BaseTargeting; m_MovementComponent = m_ComponentsObject.GetComponent(components [2]) as BaseMovement; m_ChargeMovement = m_ComponentsObject.GetComponent(components [3]) as BaseMovement; m_BuildingChargeMovement = m_ComponentsObject.GetComponent(components [4]) as BaseMovement; m_KnockedBackMovement = m_ComponentsObject.GetComponent(components [5]) as BaseMovement; m_HitByPlayerMovement = m_ComponentsObject.GetComponent(components [6]) as BaseMovement; }
// World Coords // 23 //-37 0 +37 // -23 // Local Coords // 46 //0 37 74 // 0 void Start() { player = transform; baseMovement = player.GetComponent <BaseMovement>(); levelManager = FindObjectOfType <LevelManager>(); spriteCompensation = levelManager.getWorldGrid().cellSize / 2.0f; initializePlanningSpace(); initializePlanners(); currentMouseCell = getPlayerLocationNode().GridLocation; }
bool Colliding(BaseMovement other) { // SAT // get my local X and Y Vector3 myX = localAxes[0]; Vector3 myY = localAxes[1]; // get other object's local X and Y Vector3 otherX = other.localAxes[0]; Vector3 otherY = other.localAxes[1]; // now we can actually check collisions along the 4 axes // my x if (!CollidingOnAxis(myX, other)) { return(false); } // my y if (!CollidingOnAxis(myY, other)) { return(false); } // other x if (!CollidingOnAxis(otherX, other)) { return(false); } // other y if (!CollidingOnAxis(otherY, other)) { return(false); } // all axes failed => they were colliding // at this point, the MTV is up to date // so make sure that MTV always faces us, the current object Vector3 otherToMe = transform.position - other.transform.position; //if (Vector3.Dot(minimumTranslationVector, otherToMe) < 0.0f) // minimumTranslationVector *= -1.0f; if (Vector3.Dot(debugManager.MTV, otherToMe) < 0.0f) { debugManager.MTV *= -1.0f; } return(true); }
void OnSceneGUI() { BaseMovement o = target as BaseMovement; if (o == null || o.rb == null) { return; } Handles.color = Color.blue; Vector3 pos = Vector3.up * o.feetHeight + o.rb.position; //Vector3 pos = Vector3.zero + o.transform.position; o.feetHeight = Handles.ScaleValueHandle(o.feetHeight, pos, Quaternion.Euler(90f, 0f, 0f), 3.5f, Handles.RectangleHandleCap, 0.1f); }
void Place(GameObject[] objects) { for (int i = 0; i < objects.Length; i++) { // first, get movement component BaseMovement movement = objects[i].GetComponent <BaseMovement>(); // random position objects[i].transform.position = new Vector3(Random.Range(-X, X), Random.Range(-Y, Y)); // random velocity movement.velocity = new Vector3(Random.Range(-4.0f, 4.0f), Random.Range(-4.0f, 4.0f)); // random omega movement.omega = Random.Range(Mathf.PI, Mathf.PI); } }
public void InitializeAffectMovement(AffectMovementType type, float value, Vector2 knockback) { affectType = type; amount = value; targetMovement = target.GetComponent <BaseMovement>(); switch (affectType) { case AffectMovementType.Halt: if (targetMovement == null) { return; } if (targetMovement is EntityMovement) { if (((EntityMovement)targetMovement).Grounded || ((EntityMovement)targetMovement).Platformed) { target.GetComponent <Rigidbody2D>().velocity = Vector2.zero; } } targetMovement.CanMove = false; targetMovement.CanPivot = false; break; case AffectMovementType.Knockback: target.GetComponent <Rigidbody2D>().velocity = Vector2.zero; targetMovement.CanMove = false; target.GetComponent <Rigidbody2D>().AddForce(knockback * value); break; case AffectMovementType.AlterSpeed: mod = new StatCollection.StatModifer(amount, StatCollection.StatModificationType.Multiplicative); //Debug.Log("Applyin a mod of " + mod.value); StatAdjustmentManager.ApplyTrackedStatMod(source, targetEntity, Constants.BaseStatType.MoveSpeed, mod); //CombatManager.ApplyUntrackedStatMod(source, target.GetComponent<Entity>(), Constants.BaseStatType.MoveSpeed, amount, StatCollection.StatModificationType.Multiplicative); break; } }
private void Update(EvaluationContext context) { if (IsAnyInputDirty() || !_initialized) { _breeds.TypedElements[0].ComfortZones = ComfortZones.GetValue(context); _breeds.TypedElements[0].Emit = Emit.GetValue(context); _breeds.TypedElements[0].SideAngle = SideAngle.GetValue(context) * MathUtils.ToRad; _breeds.TypedElements[0].SideRadius = SideRadius.GetValue(context); _breeds.TypedElements[0].FrontRadius = FrontRadius.GetValue(context); _breeds.TypedElements[0].BaseMovement = BaseMovement.GetValue(context); _breeds.TypedElements[0].BaseRotation = BaseRotation.GetValue(context) * MathUtils.ToRad; _breeds.TypedElements[0].MoveToComfort = MoveToComfort.GetValue(context); _breeds.TypedElements[0].RotateToComfort = RotateToComfort.GetValue(context) * MathUtils.ToRad; _initialized = true; } OutBuffer.Value = _breeds; }
void SetControlsEnabled(GameObject playerObject, bool enabled) { BaseMovement movementScript = playerObject.GetComponent <BaseMovement>(); BattleScript combatScript = playerObject.GetComponent <BattleScript>(); ThirdPersonCamera cameraScript = Camera.main.GetComponent <ThirdPersonCamera>(); if (cameraScript != null) { cameraScript.enabled = enabled; } if (movementScript != null) { movementScript.enabled = enabled; } if (combatScript != null) { combatScript.enabled = enabled; } }
// The function to call when creating a clone to initialise everything public void Create(BaseMovement moveComponent, BaseCombat combatComponent, Vector3 startingPos, float activeTime, GameObject target, GameObject projectilePrefab) { // Initialise the target m_Target = target; // Add a navmesh agent m_Agent = (NavMeshAgent)gameObject.AddComponent(Constants.NAV_AGENT); // Create a move component of the same type as the one passed System.Type movementType = moveComponent.GetType(); string moveType = movementType.ToString(); m_MovementComponent = (BaseMovement)gameObject.AddComponent(moveType); // Set the agent of that move component if (m_MovementComponent != null) { m_MovementComponent.SetAgent(m_Agent); } //Create a combat component of the same type as the one passed System.Type combatType = combatComponent.GetType(); string comType = combatType.ToString(); m_CombatComponent = (BaseCombat)gameObject.AddComponent(comType); // Initialise the projectile prefab if (m_CombatComponent != null) { m_CombatComponent.SetProjectilePrefab(projectilePrefab); } // Set the active timer m_ActiveTimer = activeTime; // move to the starting attack position if (m_MovementComponent != null) { m_MovementComponent.Movement(startingPos); } m_Health = 0.5f; }
float MaxAlongOtherMTV(BaseMovement other, List <Vector3> closestPoints) { // this function is almost identitical to MinAlongMyMTV // with two key differences: // 1. we track a MAX instead of a MIN // 2. it's along the MTV of the OTHER object Vector3 currentPoint = other.points[0]; //float currentMax = Vector3.Dot(currentPoint, other.minimumTranslationVector); float currentMax = Vector3.Dot(currentPoint, debugManager.MTV); // variable to help debug //Vector3 mtv = other.minimumTranslationVector; Vector3 mtv = debugManager.MTV; //mtv = minimumTranslationVector; int numPoints = other.points.Length; for (int i = 0; i < numPoints; i++) { currentPoint = other.points[i]; //float dot = Vector3.Dot(currentPoint, other.minimumTranslationVector); float dot = Vector3.Dot(currentPoint, mtv); if (Mathf.Abs(dot - currentMax) < EPSILON + MARGIN_OF_ERROR) { closestPoints.Add(currentPoint); } else if (dot > currentMax + EPSILON) { currentMax = dot; closestPoints.Clear(); closestPoints.Add(currentPoint); } } return(currentMax); }
public void DoIMove(BaseMovement movementToDo) { /* float distanceToTarget = Vector3.Distance(target.position, transform.position); * if (movementToDo != null) * switch (movementToDo.movementType) * { * case BaseMovement.MovementType.goToTarget: * goToTarget = true; * runAway = false; * standStill = false; * break; * case BaseMovement.MovementType.runAway: * goToTarget = false; * runAway = true; * standStill = false; * break; * case BaseMovement.MovementType.standStill: * goToTarget = false; * runAway = false; * standStill = true; * break; * }*/ }
public override void SetComponents(string[] components) { m_ComponentsObject = transform.FindChild (Constants.COMPONENTS_STRING).gameObject; m_CombatComponent = m_ComponentsObject.GetComponent (components [0]) as BaseCombat; m_TargetingComponent = m_ComponentsObject.GetComponent (components [1]) as BaseTargeting; m_MovementComponent = m_ComponentsObject.GetComponent (components [2]) as BaseMovement; m_ChargeMovement = m_ComponentsObject.GetComponent (components [3]) as BaseMovement; m_BuildingChargeMovement = m_ComponentsObject.GetComponent (components [4]) as BaseMovement; m_KnockedBackMovement = m_ComponentsObject.GetComponent (components [5]) as BaseMovement; m_HitByPlayerMovement = m_ComponentsObject.GetComponent (components [6]) as BaseMovement; }