예제 #1
0
    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;
        }
    }
예제 #2
0
    private void Start()
    {
        nextStateUpdateTime = Time.time + stateUpdateTime;

        aiAttributes = GetComponent <AiAttributes>();

        CurrentOrder = null;
    }
예제 #3
0
    private void Start()
    {
        aiAttributes = GetComponent <AiAttributes>();

        currentTargetAsteroid = GetRandomAsteroid();

        miningTimer = Time.time + aiAttributes.miningTime;
    }
예제 #4
0
    private void Start()
    {
        Target = null;

        aiAttributes      = GetComponentInParent <AiAttributes>();
        targetUpdateTimer = Time.time + targetUpdateTime;
        attachedTurret    = GetComponent <Turret>();
    }
예제 #5
0
    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));
    }
예제 #6
0
    private void Start()
    {
        aiAttributes = GetComponent <AiAttributes>();

        patrolTarget = getPatrolLocation();
        if (patrolTarget != null)
        {
            waitingTimer = Random.Range(aiAttributes.minWaitingTimeAtTarget, aiAttributes.maxWaitingTimeAtTarget);
        }
    }
예제 #7
0
    private void Start()
    {
        nextStateUpdateTime = Time.time + stateUpdateTime;

        aiAttributes = GetComponent <AiAttributes>();

        CurrentOrder = null;

        attachedFactory = GetComponent <LimitedProductionStructureTag>();
    }
예제 #8
0
    private void Start()
    {
        aiAttributes = GetComponent <AiAttributes>();

        currentTarget = getRandomEnemyCivilian();

        if (currentTarget != null)
        {
            targetPos    = currentTarget.transform.position;
            waitingTimer = Random.Range(aiAttributes.minWaitingTimeAtTarget, aiAttributes.maxWaitingTimeAtTarget);
        }
    }
예제 #9
0
    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;
        }
    }
예제 #10
0
    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>();
        }
    }
예제 #11
0
    private void Start()
    {
        aiAttributes = GetComponent <AiAttributes>();

        buyingFrom = getBestDeal();
    }
예제 #12
0
 private void Start()
 {
     aiAttributes         = GetComponent <AiAttributes>();
     attachedFactory      = GetComponent <LimitedProductionStructureTag>();
     attachedFactoryCargo = attachedFactory.factory.GetComponent <MetalCargo>();
 }
예제 #13
0
 private void Start()
 {
     aiAttributes = GetComponent <AiAttributes>();
 }
예제 #14
0
    private void Start()
    {
        aiAttributes = GetComponent <AiAttributes>();

        sellingTo = getBestDeal();
    }