示例#1
0
 public Option(VehicleControls controlOption, VehicleState resultingState)
 {
     ControlOption  = controlOption;
     ResultingState = resultingState;
     TimesRun       = 0;
     Payout.InitializeForAccumulation();
 }
示例#2
0
    // Use this for initialization
    void Start()
    {
        structureList.AddRange(structures);

        for (int i = 0; i < structures.Length; i++)
        {
            structurePositions.Add(i * structureSpacing);
        }

        AddStructures();
        headElement = structuresInPlay[structuresInPlay.Count - 1] as GameObject;
        lastElement = structuresInPlay[0] as GameObject;
        trucks.Add(gameObject);
        vehicleControls = GetComponent <VehicleControls>();
        myRigidbody     = GetComponent <Rigidbody2D>();
        transform.Find("Body").localScale    = new Vector3(1, (structuresInPlay.Count * 2), 0);
        transform.Find("Body").localPosition = new Vector3(0, structuresInPlay.Count - 1, 0);
        if (!reversePosition)
        {
            reverseFactor = -1;
        }
        GameObject body = transform.Find("Body").gameObject;

        body.GetComponent <MeshRenderer>().material.color = GetComponent <Entity>().affinity.GetComponent <Fleet>().teamColor;
    }
示例#3
0
    public override void Start()
    {
        base.Start ();
        driveBehavior = DriveBehavior.None;

        maxStartupTime = Random.Range (3, 7);
        vehicleControls = GetComponent<VehicleControls>();
        turretTransform = transform.Find ("Turret");
        turret = turretTransform.GetComponent<SheepTurret>();
        turret.owner = gameObject;
        myRigidBody = GetComponent<Rigidbody2D>();
        if(reversePosition){
            reverseFactor *= -1;
        }
        acceleration = Random.value;

        enemyPlayer = GetComponent<Entity>().EnemyPlayer();

        DeterminePersonality();

        if(reversePosition){
            OrientationHelper.RotateTransform(turretTransform, 180);
        }
        foreach(Transform child in transform.Find ("Body").transform){
            CarWheel wheel = child.GetComponent<CarWheel>();
            if(wheel){
                wheel.vehicleControls = vehicleControls;
            }
        }
    }
示例#4
0
 public override void Start()
 {
     base.Start();
     speed = 2;
     enemyPlayer = GetComponent<Entity>().EnemyPlayer();
     vehicleControls = GetComponent<VehicleControls>();
 }
示例#5
0
        private OptionPayout RolloutStateAndGetPayout(SimulationState simState)
        {
            OptionPayout payout = new OptionPayout();

            payout.InitializeForExpand();
            SimulationState iterationState = simState;
            const int       kIterations    = 22;

            for (int i = 0; i < kIterations; ++i)
            {
                VehicleState     controlledVehicle   = iterationState.GetVehicle(mControlledID);
                VehiclePrototype controlledPrototype = mSimData.GetVehiclePrototype(mControlledID);
                mControlInputMock[mControlledID] = new VehicleControls(GetRandomControl(controlledVehicle, controlledPrototype, mRandom, mDeltaTime));

                VehicleState     targetVehicle   = iterationState.GetVehicle(mTargetID);
                VehiclePrototype targetPrototype = mSimData.GetVehiclePrototype(mTargetID);
                mControlInputMock[mTargetID] = new VehicleControls(GetRandomControl(targetVehicle, targetPrototype, mRandom, mDeltaTime));

                iterationState = SimulationProcessor.ProcessState(iterationState, mSimData, mControlInputMock, mDeltaTime);

                EvaluateIterationPayout(iterationState, ref payout, controlledVehicle.DynamicTransform, controlledPrototype, targetVehicle.DynamicTransform, targetPrototype);
            }
            ComputeResidueRolloutHits(iterationState, ref payout);
            return(payout);
        }
示例#6
0
    public override void Start()
    {
        base.Start();
        driveBehavior = DriveBehavior.None;

        vehicleControls = GetComponent <VehicleControls>();
        turretTransform = transform.Find("Turret");
        turret          = turretTransform.GetComponent <SheepTurret>();
        turret.owner    = gameObject;
        myRigidBody     = GetComponent <Rigidbody2D>();
        if (reversePosition)
        {
            reverseFactor *= -1;
        }
        acceleration = Random.value;

        if (reversePosition)
        {
            OrientationHelper.RotateTransform(turretTransform, 180);
        }
        foreach (Transform child in transform.Find("Body").transform)
        {
            CarWheel wheel = child.GetComponent <CarWheel>();
            if (wheel)
            {
                wheel.vehicleControls = vehicleControls;
            }
        }
    }
示例#7
0
 public override void Start()
 {
     base.Start();
     speed           = 2;
     enemyPlayer     = GetComponent <Entity>().EnemyPlayer();
     vehicleControls = GetComponent <VehicleControls>();
 }
示例#8
0
    void Start()
    {
        gameMarker          = GameObject.Find("Game Root/GameMarker");
        currentStunDuration = maxStunDuration;
        myRigidbody         = GetComponent <Rigidbody2D>();
        players.Add(gameObject);
        playerHitState        = gameObject.AddComponent <PlayerHitState>() as PlayerHitState;
        playerHitState.player = gameObject;
        GameObject vulcanObject = Instantiate(Resources.Load("Vulcan"), transform.position, Quaternion.identity) as GameObject;

        vulcanObject.transform.parent = transform;
        vulcan        = vulcanObject.GetComponent <Vulcan>() as Vulcan;
        vulcan.player = this;
        GameObject bombLauncherObject = Instantiate(Resources.Load("Bomb Launcher"), transform.position, Quaternion.identity) as GameObject;

        bombLauncherObject.transform.parent = transform;
        bombLauncher         = bombLauncherObject.GetComponent <BombLauncher>() as BombLauncher;
        bombLauncher.player  = this;
        shotgun              = gameObject.AddComponent <Shotgun>() as Shotgun;
        shotgun.player       = this;
        gigaBeam             = gameObject.AddComponent <GigaBeam>() as GigaBeam;
        gigaBeam.player      = this;
        magnetMissile        = gameObject.AddComponent <MagnetMissile>() as MagnetMissile;
        magnetMissile.player = this;
        reversePosition      = GetComponent <Entity>().affinity.GetComponent <Fleet>().reversePosition;
        body = transform.Find("Body").gameObject;
        body.GetComponent <SpriteRenderer>().color = GetComponent <Entity>().affinity.GetComponent <Fleet>().teamColor;
        shieldObject = Instantiate(shieldPrefab, transform.position, Quaternion.identity) as GameObject;
        shieldObject.transform.parent = gameObject.transform;
        shield        = shieldObject.GetComponent <Shield>();
        shield.player = this;
        playerHitState.SwitchToInvincible();
        damageBehavior = GetComponent <DamageBehavior>();
        currentExValue = GetComponent <Entity>().affinity.GetComponent <Fleet>().lastExValue;
        gameObject.transform.eulerAngles = new Vector3(
            gameObject.transform.eulerAngles.x,
            gameObject.transform.eulerAngles.y,
            gameObject.transform.eulerAngles.z - 90);
        vehicleControls = GetComponent <VehicleControls>();
        if (reversePosition)
        {
            reverseIndex *= -1;
        }
        GameObject playerHud = Instantiate(Resources.Load("HUD/PlayerHUD"), transform.position, Quaternion.identity) as GameObject;

        playerHud.transform.parent = GameObject.Find("WorldspaceHUD").transform;
        playerHud.GetComponent <PlayerHUD>().player = this;
        defaultColor = body.GetComponent <SpriteRenderer>().color;
        foreach (Transform child in body.transform)
        {
            CarWheel wheel = child.GetComponent <CarWheel>();
            if (wheel)
            {
                wheel.vehicleControls = vehicleControls;
            }
        }
        currentExValue = maxExValue;
    }
示例#9
0
 // Use this for initialization
 void Start()
 {
     VControls = gameObject.GetComponent <VehicleControls>();
     if (!isOccupied)
     {
         ((Camera)gameObject.transform.Find("Camera").gameObject.GetComponent("Camera")).enabled = false;
     }
     if (!isOccupied)
     {
         ((AudioListener)gameObject.transform.Find("Camera").gameObject.GetComponent("AudioListener")).enabled = false;
     }
 }
示例#10
0
文件: GameManager.cs 项目: narkos/DCT
 public void HandleStartTrip()
 {
     if (SceneManager.GetActiveScene().buildIndex != 0)
     {
         VehicleControls player     = GameObject.FindGameObjectWithTag("Player").GetComponent <VehicleControls>();
         CameraManager   camManager = GameObject.FindGameObjectWithTag("MainCamera").GetComponent <CameraManager>();
         if (player != null)
         {
             player.SetControlType(VehicleControls.ControlType.Mouse);
         }
         if (camManager != null)
         {
             camManager.SetCameraMode(CameraManager.CameraMode.BirdsEye);
         }
     }
 }
示例#11
0
文件: GameManager.cs 项目: narkos/DCT
 public void HandleEndTrip()
 {
     //queuedSceneChange = 0;
     if (SceneManager.GetActiveScene().buildIndex != 0)
     {
         VehicleControls player     = GameObject.FindGameObjectWithTag("Player").GetComponent <VehicleControls>();
         CameraManager   camManager = GameObject.FindGameObjectWithTag("MainCamera").GetComponent <CameraManager>();
         if (player != null)
         {
             player.SetControlType(VehicleControls.ControlType.Off);
         }
         if (camManager != null)
         {
             camManager.SetCameraMode(CameraManager.CameraMode.Orbit);
         }
     }
 }
示例#12
0
    // Use this for initialization
    void Start()
    {
        structureList.AddRange (structures);

        for(int i = 0; i < structures.Length; i++){
            structurePositions.Add (i * structureSpacing);
        }

        AddStructures();
        headElement = structuresInPlay[structuresInPlay.Count - 1] as GameObject;
        lastElement = structuresInPlay[0] as GameObject;
        trucks.Add(gameObject);
        vehicleControls = GetComponent<VehicleControls>();
        myRigidbody = GetComponent<Rigidbody2D>();
        transform.Find ("Body").localScale = new Vector3(1, (structuresInPlay.Count * 2), 0);
        transform.Find ("Body").localPosition = new Vector3(0, structuresInPlay.Count - 1, 0);
        if(!reversePosition) reverseFactor = -1;
        GameObject body = transform.Find ("Body").gameObject;
        body.GetComponent<MeshRenderer>().material.color = GetComponent<Entity>().affinity.GetComponent<Fleet>().teamColor;
    }
示例#13
0
        public void ResetAndSetup(SimulationState currentSimState)
        {
            mTargetRootState = currentSimState.GetVehicle(mTargetID);
            mEnemyProjectiles.Clear();

            VehiclePrototype controlledPrototype = mSimData.GetVehiclePrototype(mControlledID);
            VehicleState     controlledState     = currentSimState.GetVehicle(mControlledID);

            var projectiles = currentSimState.GetProjectiles(mTargetID);

            //Cache the projectile states for next frame, but onyl those with a chance of hiting
            foreach (var projectile in projectiles)
            {
                Vector2 relativePosition = controlledState.DynamicTransform.Position - projectile.Position;
                Vector2 relativeVelocity = controlledState.DynamicTransform.Velocity - projectile.Velocity;
                if (Vector2.Dot(relativePosition, relativeVelocity) < 0f)
                {
                    if (!SimulationProcessor.ProjectileHitsVehicle(controlledState.DynamicTransform, controlledPrototype, projectile, mDeltaTime))
                    {
                        DynamicPosition2 updatedProjectile = new DynamicPosition2(projectile.Position + mDeltaTime * projectile.Velocity, projectile.Velocity);
                        mEnemyProjectiles.Add(projectile);
                    }
                }
            }


            mOptions.Clear();
            controlledPrototype.ControlConfig.GetPossibleControlChanges(controlledState.ControlState, mDeltaTime, mControlOptionCache);
            foreach (var driveControlOption in mControlOptionCache)
            {
                VehicleControls   controlOption         = new VehicleControls(driveControlOption);
                DynamicTransform2 resultingDynamicState = controlledPrototype.VehicleDrive(controlledState.DynamicTransform, driveControlOption, mDeltaTime);
                VehicleState      resultingVehicleState = new VehicleState(resultingDynamicState, driveControlOption); //We should not care for the gun state... I thnk...

                Option option = new Option(controlOption, resultingVehicleState);
                mOptions.Add(option);
            }
            mControlOptionCache.Clear();
            mIterations = 0;
        }
 private void Update()
 {
     if (currentlySelected.currentVehicle)
     {
         vehicleControls = currentlySelected.currentVehicle.GetComponent <VehicleControls>();
         if (vehicleControls.breakingDown)
         {
             gameObject.GetComponent <Image>().color = new Color32(0, 212, 0, 255);
             buttonText.text = "Resume";
         }
         else
         {
             gameObject.GetComponent <Image>().color = new Color32(69, 69, 255, 255);
             buttonText.text = "Break Down";
         }
     }
     else
     {
         gameObject.GetComponent <Image>().color = new Color32(69, 69, 255, 255);
         buttonText.text = "Break Down";
     }
 }
示例#15
0
 private void Update()
 {
     if (currentlySelected.currentVehicle)
     {
         vehicleControls = currentlySelected.currentVehicle.GetComponent <VehicleControls>();
         if (vehicleControls.emergencyBraked)
         {
             gameObject.GetComponent <Image>().color = new Color32(0, 212, 0, 255);
             buttonText.text = "Resume";
         }
         else
         {
             gameObject.GetComponent <Image>().color = new Color32(253, 46, 46, 255);
             buttonText.text = "Emergency Brake";
         }
     }
     else
     {
         gameObject.GetComponent <Image>().color = new Color32(253, 46, 46, 255);
         buttonText.text = "Emergency Brake";
     }
 }
示例#16
0
        private void CreateAITask(uint aiID, uint targetID, float deltaTime, int iterations)
        {
            mAIIterator.Add(aiID);
            var resultPlacement = new BlockingCollection <VehicleControls>(1);

            mControlResults[aiID] = resultPlacement;
            var requestPlacement = new BlockingCollection <SimulationState>(1);

            mControlRequests[aiID] = requestPlacement;
            MonteCarloVehicleAI ai = new MonteCarloVehicleAI(aiID, targetID, deltaTime, SimulationData, iterations);   //TODO: inconsistently assuming delta time fixed here and otherwise elsewhere
            Action aiAction        = () =>
            {
                while (true)
                {
                    SimulationState state    = requestPlacement.Take();
                    VehicleControls controls = ai.ComputeControl(state);
                    resultPlacement.Add(controls);
                }
            };
            Task aiTask = new Task(aiAction);

            requestPlacement.Add(ActiveState);
            aiTask.Start();
        }
示例#17
0
 // Use this for initialization
 void Start()
 {
     VControls = gameObject.GetComponent<VehicleControls>();
     if (!isOccupied) ((Camera)gameObject.transform.Find("Camera").gameObject.GetComponent("Camera")).enabled = false;
     if (!isOccupied) ((AudioListener)gameObject.transform.Find("Camera").gameObject.GetComponent("AudioListener")).enabled = false;
 }
示例#18
0
 void Start()
 {
     gameMarker = GameObject.Find("Game Root/GameMarker");
     currentStunDuration = maxStunDuration;
     myRigidbody = GetComponent<Rigidbody2D>();
     players.Add (gameObject);
     playerHitState = gameObject.AddComponent<PlayerHitState>() as PlayerHitState;
     playerHitState.player = gameObject;
     GameObject vulcanObject = Instantiate (Resources.Load ("Vulcan"), transform.position, Quaternion.identity) as GameObject;
     vulcanObject.transform.parent = transform;
     vulcan = vulcanObject.GetComponent<Vulcan>() as Vulcan;
     vulcan.player = this;
     GameObject bombLauncherObject = Instantiate (Resources.Load ("Bomb Launcher"), transform.position, Quaternion.identity) as GameObject;
     bombLauncherObject.transform.parent = transform;
     bombLauncher = bombLauncherObject.GetComponent<BombLauncher>() as BombLauncher;
     bombLauncher.player = this;
     shotgun = gameObject.AddComponent<Shotgun>() as Shotgun;
     shotgun.player = this;
     gigaBeam = gameObject.AddComponent<GigaBeam>() as GigaBeam;
     gigaBeam.player = this;
     magnetMissile = gameObject.AddComponent<MagnetMissile>() as MagnetMissile;
     magnetMissile.player = this;
     reversePosition = GetComponent<Entity>().affinity.GetComponent<Fleet>().reversePosition;
     body = transform.Find ("Body").gameObject;
     body.GetComponent<SpriteRenderer>().color = GetComponent<Entity>().affinity.GetComponent<Fleet>().teamColor;
     shieldObject = Instantiate (shieldPrefab, transform.position, Quaternion.identity) as GameObject;
     shieldObject.transform.parent = gameObject.transform;
     shield = shieldObject.GetComponent<Shield>();
     shield.player = this;
     playerHitState.SwitchToInvincible();
     damageBehavior = GetComponent<DamageBehavior>();
     currentExValue = GetComponent<Entity>().affinity.GetComponent<Fleet>().lastExValue;
     gameObject.transform.eulerAngles = new Vector3(
         gameObject.transform.eulerAngles.x,
         gameObject.transform.eulerAngles.y,
         gameObject.transform.eulerAngles.z - 90);
     vehicleControls = GetComponent<VehicleControls>();
     if(reversePosition) reverseIndex *= -1;
     GameObject playerHud = Instantiate (Resources.Load ("HUD/PlayerHUD"), transform.position, Quaternion.identity) as GameObject;
     playerHud.transform.parent = GameObject.Find ("WorldspaceHUD").transform;
     playerHud.GetComponent<PlayerHUD>().player = this;
     defaultColor = body.GetComponent<SpriteRenderer>().color;
     foreach(Transform child in body.transform){
         CarWheel wheel = child.GetComponent<CarWheel>();
         if(wheel){
             wheel.vehicleControls = vehicleControls;
         }
     }
     currentExValue = maxExValue;
 }