Exemple #1
0
    void Start()
    {
        movementController = gameObject.AddComponent <MovementController>();
        movementController.Initialize(GetComponentInChildren <IsometricCharacterRenderer>(), GetComponent <Rigidbody2D>(), movementSpeed);       //Get direction from input

        shootingController = gameObject.AddComponent <ShootingController>();
        shootingController.Initialize(GetComponentInChildren <IsometricCharacterRenderer>(), ShootingProjectiles[0]);
    }
Exemple #2
0
 void Update()
 {
     movementController.Move(new Vector2(Input.GetAxis("Horizontal"), Input.GetAxis("Vertical")));
     if (Input.GetButtonDown("Fire"))
     {
         Vector2 shotDirection = Input.mousePosition;
         shotDirection  = Camera.main.ScreenToWorldPoint(shotDirection);
         shotDirection -= (Vector2)transform.position;
         shootingController.Fire(transform.position, shotDirection);
     }
     for (int i = 0; i < 4; i++)
     {
         if (Input.GetButtonDown("SelectWeapon" + (i + 1)) && (ShootingProjectiles[i].unlocked))
         {
             shootingController.Initialize(GetComponentInChildren <IsometricCharacterRenderer>(), ShootingProjectiles[i]);
         }
     }
 }
    void Start()
    {
        TrialActive = -1;

        IsGoaled    = false;
        IsTimedOut  = false;
        ElapsedTime = 0f;

        CurrentMaxFitness = 0f;
        FitnessList       = new List <float>(Positions.Length);

        OptimizationManager = Optimizer.GetComponent <OptimizationManager>();
        PositionCounter     = 0;

        GoalScorer = Goal.GetComponent <GoalScorerController>();

        Robot = (GameObject)Instantiate(Resources.Load("ShootingCar"), new Vector3(0f, 3f, 15f), Quaternion.identity);
        ShootingController = Robot.GetComponent <ShootingController>();
        ShootingController.Initialize(Ball, Goal);

        RobotRigidbody = Robot.GetComponent <Rigidbody>();
        BallRigidbody  = Ball.GetComponent <Rigidbody>();
    }