private void Start() { aiAttributes = GetComponent <AiAttributes>(); currentTarget = getClosestEnemy(); if (currentTarget != null) { // Get the direction the ships needs to go (away from target) targetPos = transform.position - currentTarget.transform.position; // Normalize it so that x and y put together are 1 but still preserving the direction targetPos.Normalize(); // Multiply with preferred combat distance so that the ship tries to stay there targetPos *= aiAttributes.preferredCombatDistance; // Check if the ship is too far away from preferred distance, flip the value if so if (Vector2.Distance(transform.position, currentTarget.transform.position) >= aiAttributes.preferredCombatDistance) { targetPos = -targetPos; } // Add own position so that the ship moves relative to own position targetPos += (Vector2)transform.position; } }
private void Start() { nextStateUpdateTime = Time.time + stateUpdateTime; aiAttributes = GetComponent <AiAttributes>(); CurrentOrder = null; }
private void Start() { aiAttributes = GetComponent <AiAttributes>(); currentTargetAsteroid = GetRandomAsteroid(); miningTimer = Time.time + aiAttributes.miningTime; }
private void Start() { Target = null; aiAttributes = GetComponentInParent <AiAttributes>(); targetUpdateTimer = Time.time + targetUpdateTime; attachedTurret = GetComponent <Turret>(); }
public bool UpdateOrder() { if (aiAttributes == null) { aiAttributes = GetComponent <AiAttributes>(); } return(MoveOrder.move(aiAttributes.currentManualTarget, aiAttributes.AttachedShip.speed, aiAttributes.AttachedShip.rotationSpeed, 0.2f, 0.5f, aiAttributes.AttachedRigidBody, gameObject)); }
private void Start() { aiAttributes = GetComponent <AiAttributes>(); patrolTarget = getPatrolLocation(); if (patrolTarget != null) { waitingTimer = Random.Range(aiAttributes.minWaitingTimeAtTarget, aiAttributes.maxWaitingTimeAtTarget); } }
private void Start() { nextStateUpdateTime = Time.time + stateUpdateTime; aiAttributes = GetComponent <AiAttributes>(); CurrentOrder = null; attachedFactory = GetComponent <LimitedProductionStructureTag>(); }
private void Start() { aiAttributes = GetComponent <AiAttributes>(); currentTarget = getRandomEnemyCivilian(); if (currentTarget != null) { targetPos = currentTarget.transform.position; waitingTimer = Random.Range(aiAttributes.minWaitingTimeAtTarget, aiAttributes.maxWaitingTimeAtTarget); } }
private void Start() { aiAttributes = GetComponent <AiAttributes>(); closestEnemy = getClosestEnemy(); if (closestEnemy != null) { targetPos = transform.position - closestEnemy.transform.position; targetPos.Normalize(); targetPos *= aiAttributes.fleeDistance; targetPos += (Vector2)transform.position; } }
public void HandleRightClick(Vector2 clickedPos, string faction) { if (tag.Equals(faction)) { if (CurrentOrder != null) { CurrentOrder.DestroyOrder(); } if (aiAttributes == null) { aiAttributes = GetComponent <AiAttributes>(); } aiAttributes.currentManualTarget = clickedPos; CurrentOrder = gameObject.AddComponent <ManualMoveOrder>(); } }
private void Start() { aiAttributes = GetComponent <AiAttributes>(); buyingFrom = getBestDeal(); }
private void Start() { aiAttributes = GetComponent <AiAttributes>(); attachedFactory = GetComponent <LimitedProductionStructureTag>(); attachedFactoryCargo = attachedFactory.factory.GetComponent <MetalCargo>(); }
private void Start() { aiAttributes = GetComponent <AiAttributes>(); }
private void Start() { aiAttributes = GetComponent <AiAttributes>(); sellingTo = getBestDeal(); }