void Awake()
    {
        if( mInstance != null )
        {
            Debug.LogError( string.Format( "Only one instance of PlayerAgent allowed! Destroying:" + gameObject.name +", Other:" + mInstance.gameObject.name ) );
            Destroy( gameObject );
            return;
        }

        mInstance = this;
    }
Beispiel #2
0
    void Start()
    {
        battleArea  = GetComponentInParent <BattleArea>();
        myRigidBody = GetComponent <Rigidbody>();
        Canvas canvas = FindObjectOfType <Canvas>();

        canvasRect = canvas.GetComponent <RectTransform>();
        agent      = GetComponent <PlayerAgent>();

        statusBar = Instantiate(statusBarPrefab, canvas.transform);
        battleArea.players.Add(this.gameObject);
        rotation = transform.eulerAngles.y;
    }
Beispiel #3
0
    private void OnTriggerExit(Collider other)
    {
//        Debug.Log($"Left Trigger: {other}");

        PlayerAgent playerAgent = other.gameObject.GetComponentInParent <PlayerAgent>();

        if (playerAgent != null)
        {
            playerAgent.OnPlayerTriggerExit(this.GetComponent <Collider>(), other);

            _isAttacking = false;
        }
    }
Beispiel #4
0
        internal void ViewProStopObjectUpdate(SimulationEvent ev)
        {
            String id = ((StringValue)ev["ObjectID"]).value;

            if (AllObjects.ContainsKey(id))
            {
                AllObjects[id].ShouldProject = false;
            }
            if (PlayerAgent != null)
            {
                PlayerAgent.ViewProStopObjectUpdate(ev);
            }
        }
 internal void Awake()
 {
     Instance.LogDebug($"{nameof(PlaceholderInteractionMonitor)}.{nameof(Awake)}()");
     this.playerAgent        = this.gameObject.GetComponent <PlayerAgent>();
     this.interact           = this.playerAgent.gameObject.AddComponent <Interact_ManualTimedWithCallback>();
     this.interact.OnTrigger = (Il2CppSystem.Action) this.OnTrigger;
     this.interact.OnInteractionEvaluationAbort    = (Il2CppSystem.Action) this.OnAbort;
     this.interact.AbortOnDotOrDistanceDiff        = true;
     this.interact.OnlyActiveWhenLookingStraightAt = true;
     this.interact.InteractDuration = 0.6f;
     this.UpdateInteractionMessage("Blah");
     this.interact.SetActive(true);
 }
Beispiel #6
0
    protected override void Destroy()
    {
        Logger.Instance.LogKill(stats.name);
        Gamemaster.Instance.UpdatePlayerScore(stats.score);

        PlayerAgent pa = Gamemaster.Instance.player.GetComponent <PlayerAgent>();

        pa.SetReward(.0005f); //Reward extra for destroying an enemy

        //Spawn a powerup here.
        SpawnScorePickup();

        base.Destroy();
    }
    private IEnumerator Draw(Arena arena)
    {
        PlayerAgent first  = arena.Players[0].PlayerAgent;
        PlayerAgent second = arena.Players[1].PlayerAgent;

        first.SetReward(DrawReward);
        second.SetReward(DrawReward);
        first.Done();
        second.Done();

        yield return(new WaitForFixedUpdate());

        ResetEnv(arena);
    }
    protected override void PerformAction(float timeStep)
    {
        PlayerAgent npcComponent = null;

        base.PerformAction(timeStep);
        if (!npcCreated)
        {
            if (stageComponent != null)
            {
                npcComponent = stageComponent.CreateNonPlayableCharacter(npcModel, placementNodeID, offsetWithinNode, sideToFace, isEnemy);
                npcCreated   = (npcComponent != null);
            }
        }
    }
Beispiel #9
0
    void NextPhase()
    {
        if (round < 0)
        {
            round = 0;
        }

        if (player < 0)
        {
            player = 0;
        }

        if (phase < 0)
        {
            phase = 0;
        }
        else
        {
            phase++;
        }

        if (phase >= runtimePhases[round].Count)
        {
            phase = 0;
            if (runtimePhases[round].forEachPlayer)
            {
                player++;

                if (player >= playerList.Count)
                {
                    player = 0;
                    NextRound();
                }
            }
            else
            {
                NextRound();
            }
        }

        currentPhase  = runtimePhases[round][phase];
        currentPlayer = runtimePhases[round].forEachPlayer ? playerTable[playerList[player]] : null;
        currentPhase.CurrentPlayer = currentPlayer;
        currentPhase.GameOver      = false;
        timeElapsed = 0.0f;
        finishCurrentPhase.Clear();

        currentPhase.OnEnter();
    }
Beispiel #10
0
    private void OnTriggerExit(Collider other)
    {
//        Debug.Log($"Left Trigger: {other}");

        PlayerAgent playerAgent = other.gameObject.GetComponentInParent <PlayerAgent>();

        if (playerAgent != null)
        {
            playerAgent.OnPlayerTriggerExit(this.GetComponent <Collider>(), other);

            attackStartTime = 0.0f;
            damageApplied   = 0;
            attackStarted   = false;
        }
    }
        public static bool TryGetOrCreate(PlayerAgent player, out ExtendedPlayerAgent extendedPlayer)
        {
            if (!TryGet(player, out extendedPlayer))
            {
                if (player == null)
                {
                    return(false);
                }

                extendedPlayer = new ExtendedPlayerAgent(player);
                wrapped.Add(player.GlobalID, extendedPlayer);
            }

            return(true);
        }
 public override void Clear()
 {
     /*halmeida - remove the transaction box from the manager.*/
     if (transactionAgent != null)
     {
         if ((transactionBoxManager != null) && transactionCreated)
         {
             transactionBoxManager.RemoveTransaction(gameObject);
             transactionCreated = false;
         }
         transactionAgent = null;
     }
     runningMiddleWave = false;
     base.Clear();
 }
Beispiel #13
0
        public void Setup(FPSCamera camera, PlayerAgent agent)
        {
            FpsCamera   = camera;
            PlayerAgent = agent;

            m_origin = new GameObject("Origin").AddComponent <PlayerOrigin>();
            m_origin.Setup(PlayerAgent);
            m_snapTurn = gameObject.AddComponent <Snapturn>();
            m_snapTurn.Setup(m_origin);

            gameObject.AddComponent <VRWorldSpaceUI>();

            m_movementVignette = gameObject.AddComponent <MovementVignette>();
            m_movementVignette.Setup(agent.Locomotion, GetComponent <PostProcessingBehaviour>());

            m_weaponRadial = gameObject.AddComponent <WeaponRadialMenu>();
            m_weaponRadial.Setup(m_origin.transform);

            m_weaponAmmoHolo = gameObject.AddComponent <WeaponAmmoHologram>();
            m_weaponAmmoHolo.Setup();

            GameObject laserPointer = new GameObject("LaserPointer");

            m_pointer = laserPointer.AddComponent <LaserPointer>();


            m_fade = FpsCamera.gameObject.AddComponent <CollisionFade>();
            m_fade.Setup(PlayerAgent);

            FpsCamera.gameObject.AddComponent <SteamVR_Camera>();
            FpsCamera.gameObject.AddComponent <VRRendering>();
            FpsCamera.gameObject.AddComponent <SteamVR_Fade>();

            m_watch = Instantiate(VRAssets.GetWatchPrefab(), Vector3.zero, Quaternion.identity, null).AddComponent <Watch>();
            m_watch.Setup(m_origin.transform);

            m_haptics = gameObject.AddComponent <Haptics>();
            m_haptics.Setup();

            m_bhapticsIntegration = gameObject.AddComponent <BhapticsIntegration>();
            m_bhapticsIntegration.Setup(agent);

            PlayerLocomotionEvents.OnPlayerEnterLadder += PlayerEnteredLadder;
            SteamVR_Events.NewPosesApplied.Listen(new Action(OnNewPoses));
            VRConfig.configLightResMode.SettingChanged += LightResChanged;

            RefreshClusteredRenderingResolution();
        }
        private void PlayerInteractedHaptics(PlayerAgent source)
        {
            if (!VRConfig.configUseBhaptics.Value || (source != null && source != m_player))
            {
                return;
            }

            if (Controllers.mainControllerType == HandType.Left)
            {
                m_hapticPlayer.SubmitRegistered(ARMS_INTERACT_ITEM_L_KEY);
            }
            else
            {
                m_hapticPlayer.SubmitRegistered(ARMS_INTERACT_ITEM_R_KEY);
            }
        }
Beispiel #15
0
    private void OnTriggerEnter(Collider other)
    {
//        Debug.Log($"Triggered: {other}");

        PlayerAgent playerAgent = other.gameObject.GetComponentInParent <PlayerAgent>();

        if (playerAgent != null)
        {
            playerAgent.OnPlayerTriggerEnter(this.GetComponent <Collider>(), other);

            if (!player.IsPotionActive)
            {
                _isAttacking = true;
            }
        }
    }
 void Start()
 {
     playerAgent       = FindObjectOfType <PlayerAgent>();
     gameOver          = false;
     restart           = false;
     earthPassed       = false;
     restartText.text  = "";
     gameOverText.text = "";
     score             = 0;
     UpdateScore();
     playerAgent.Initialize(Instantiate(playerShip), this);
     StartCoroutine(SpawnWaves());
     StartCoroutine(SpawnBosses());
     startTime = Time.time;
     bosscount = 1;
 }
Beispiel #17
0
    public void AgentOnTriggerStay(PlayerAgent agent, Collider other)
    {
        if (!other.gameObject.activeInHierarchy)
        {
            return;
        }

        if (other.CompareTag("shop"))
        {
//            Debug.Log("Still at shop!", other);
        }
        else if (other.CompareTag("player-damage"))
        {
//            GameCoordinator.Instance.Health -= 1;
        }
    }
Beispiel #18
0
 // Use this for initialization
 void Start()
 {
     // Load the table manager
     tm        = transform.parent.GetComponent <TableManager>();
     opponent  = tm.PlayerAgents[Mathf.Abs(player - 1)];
     goal      = tm.Goals[player];
     play_area = tm.PlayArea;
     if (player == 0)
     {
         direction_of_play = new Vector3(1.0f, 0.0f, 0.0f);
     }
     else
     {
         direction_of_play = new Vector3(-1.0f, 0.0f, 0.0f);
     }
 }
 public void SetTargetPlayer(PlayerAgent newTargetPlayer, float newLerpFactor = 0f)
 {
     targetPlayer = newTargetPlayer;
     if (targetPlayer != null)
     {
         targetPlayerTransform = targetPlayer.gameObject.transform;
         targetMode            = TARGET_MODE_PLAYER;
         targetReached         = false;
         targetApproach        = TARGET_APPROACH_LERP;
         lerpFactorPosition    = (newLerpFactor > 0f) ? newLerpFactor : DEFAULT_LERP_FACTOR;
         GetOrthoLerpFromPositionLerp();
     }
     else
     {
         ResetTargetting();
     }
 }
    public virtual void StartInteraction(PlayerAgent playerAgent)
    {
        if (CurrentUser != null)
        {
            Logger.Log($"Cannot start interaction as user({CurrentUser}) already using it");
            return;
        }

        Logger.Log($"StartInteraction user \"{playerAgent}\"");
        CurrentUser = playerAgent;
        if (Icon != null)
        {
            Icon.SetBeingUsed(true);
        }

        AudioManger.PlayEvent("Interact");
    }
Beispiel #21
0
        public static void OnPlayerSpawned(FPSCamera fpsCamera, PlayerAgent playerAgent)
        {
            if (!playerAgent.IsLocallyOwned)
            {
                Log.Error("Got playerAgent spawn but we aren't the owner!?");
            }
            Log.Info("Player and fpscamera have been spawned, references have been set...");
            m_currentFPSCameraRef   = fpsCamera;
            m_currentPlayerAgentRef = playerAgent;

            // Normally we add VR components after the player has been spawned
            // If a player rejoins he is destroyed in the elevator and respawned, so we need to check if this happens and add VR components if needed
            if (FocusStateEvents.IsInGame())
            {
                Log.Debug("Player spawned while an in-game state was active");
                Current.HandleIngameFocus();
            }
        }
Beispiel #22
0
        internal void ViewProMotionUpdate(SimulationEvent ev)
        {
            String id = ((StringValue)ev["ObjectID"]).value;

            if (AllObjects.ContainsKey(id))
            {
                SimObject ob = AllObjects[id];
                ob.ShouldProject       = true;
                ob.Location            = ((LocationValue)ev["Location"]);
                ob.DestinationLocation = ((LocationValue)ev["DestinationLocation"]);
                ob.Throttle            = ((DoubleValue)ev["Throttle"]).value;
                ob.Velocity            = BehaviorHelper.ComputeVelocityVector(ob.Location, ob.DestinationLocation, ob.MaximumSpeed, ob.Throttle);
            }
            if (PlayerAgent != null)
            {
                PlayerAgent.ViewProMotionUpdate(ev);
            }
        }
 /*halmeida - this function receives an index that is valid across all relevant arrays and denotes
  * an element that is not null across all relevant arrays.*/
 protected override void Trigger(int triggerIndex)
 {
     if (transactionAgent == null)
     {
         transactionAgent = triggerComponents[triggerIndex];
         /*halmeida - the playerComponent is garanteed to be not null and not dead, because this was previously tested.*/
         payment             = paymentInitialValue;
         paymentChangeFactor = PAYMENT_CHANGE_FACTOR_1;
         paymentsDone        = 0;
         /*halmeida - open the transaction interface element.*/
         if ((transactionBoxManager != null) && transactionAgent.GetTransactionsTrigger())
         {
             transactionCreated = transactionBoxManager.CreateTransaction(gameObject, this, VERTICAL_DISTANCE_TO_BOX, cost,
                                                                          paid, payment, true, true, worldSpaceGaugeModel);
         }
     }
     base.Trigger(triggerIndex);
 }
    protected override void RemoveTriggeringObject(int triggeringIndex)
    {
        PlayerAgent triggeringToRemove = null;

        if (transactionAgent != null)
        {
            triggeringToRemove = triggeringComponents[triggeringIndex];
            if (transactionAgent == triggeringToRemove)
            {
                if ((transactionBoxManager != null) && transactionCreated)
                {
                    transactionBoxManager.CloseTransaction(gameObject);
                    transactionCreated = false;
                }
                transactionAgent = null;
            }
        }
        base.RemoveTriggeringObject(triggeringIndex);
    }
Beispiel #25
0
    private void OnTriggerEnter(Collider other)
    {
//        Debug.Log($"Triggered: {other}");

        PlayerAgent playerAgent = other.gameObject.GetComponentInParent <PlayerAgent>();

        if (playerAgent != null)
        {
            playerAgent.OnPlayerTriggerEnter(this.GetComponent <Collider>(), other);

            if (controller.IsAttacking)
            {
                attackStartTime = Time.time;
                damageApplied   = 0;

                attackStarted = true;
            }
        }
    }
        private void Start()
        {
            playerAgent = GetComponentInParent <PlayerAgent>();

            // get the transform of the main camera
            if (Camera.main != null)
            {
                m_Cam = Camera.main.transform;
            }
            else
            {
                Debug.LogWarning(
                    "Warning: no main camera found. Third person character needs a Camera tagged \"MainCamera\", for camera-relative controls.", gameObject);
                // we use self-relative controls in this case, which probably isn't what the user wants, but hey, we warned them!
            }

            // get the third person character ( this should never be null due to require component )
            m_Character = GetComponent <ThirdPersonCharacter>();
        }
Beispiel #27
0
 void ResetGame()
 {
     scores[0] = 0;
     scores[1] = 0;
     scores[2] = 0;
     scores[3] = 0;
     foreach (GameObject player in players)
     {
         PlayerControl agent = player.GetComponent <PlayerControl>();
         agent.PlayerReset();
         if (agent.isAgent)
         {
             PlayerAgent pa = player.GetComponent <PlayerAgent>();
             pa.Done();
         }
     }
     Debug.Log("Restarted Game");
     gameTime = 0f;
 }
Beispiel #28
0
    protected virtual void ApplyContinuousEffect(PlayerAgent triggeringComponent, float timeStep)
    {
        int applicableEffect = 0;

        if (triggeringComponent != null)
        {
            switch (effectType)
            {
            case ItemData.EffectType.HP:
                accumulatedEffect += timeStep * effectSpeed;
                applicableEffect   = (int)accumulatedEffect;
                if (applicableEffect != 0)
                {
                    accumulatedEffect -= applicableEffect;
                    triggeringComponent.AddToCurrentHP(applicableEffect, false);
                }
                break;
            }
        }
    }
        static void Postfix(FPSCamera __instance, PlayerAgent ___m_owner)
        {
            if (!PlayerVR.VRSetup)
            {
                return;
            }

            // Repeat position inject or the transforms will get out of sync (Unity transform handling mumbo jumbo ensues, frame later or frame behind tracking)
            if (VRSettings.VR_TRACKING_TYPE.Equals(TrackingType.PositionAndRotation) && !FocusStateManager.CurrentState.Equals(eFocusState.InElevator))
            {
                __instance.Position = ___m_owner.PlayerCharacterController.SmoothPosition + HMD.GetPosition();
            }

            if ((VRSettings.VR_TRACKING_TYPE.Equals(TrackingType.PositionAndRotation) || VRSettings.VR_TRACKING_TYPE.Equals(TrackingType.Rotation)))
            {
                Vector3 euler = HMD.GetVRCameraEulerRotation();
                AccessTools.FieldRefAccess <LookCameraController, float>((LookCameraController)__instance, "m_pitch") = euler.x;
                AccessTools.FieldRefAccess <LookCameraController, float>((LookCameraController)__instance, "m_yaw")   = euler.y;
            }
        }
Beispiel #30
0
    public void AgentOnTriggerEnter(PlayerAgent agent, Collider other)
    {
        if (!other.gameObject.activeInHierarchy)
        {
            return;
        }

        if (other.CompareTag("shop"))
        {
            Debug.Log("At a shop!", other);
            LevelManager.ChangeState(GameLevelManager.GameState.InStore);
        }
        else if (other.CompareTag("enemy"))
        {
            //
        }
        else if (other.CompareTag("Finish"))
        {
            LevelManager.ChangeState(GameLevelManager.GameState.Won);
        }
    }
Beispiel #31
0
    void gameFinish()
    {
        Debug.Log("finish");
        remainedPlayers = allPlayers;

        mag.newMagnetic();
        for (int i = 0; i < spawnlist.Length; i++)
        {
            Transform temp        = spawnlist[i];
            int       randomIndex = Random.Range(i, spawnlist.Length);
            spawnlist[i]           = spawnlist[randomIndex];
            spawnlist[randomIndex] = temp;
        }

        for (int i = 0; i < playerlist.Length; i++)
        {
            playerlist[i].transform.position = spawnlist[i].position;
            PlayerAgent pa = playerlist[i].GetComponent <PlayerAgent>();
            playerlist[i].GetComponent <PlayerAgent>().Done();
        }
    }
Beispiel #32
0
    void Awake()
    {
        if( mInstance != null )
        {
            Debug.LogError( string.Format( "Only one instance of PlayerAgent allowed! Destroying:" + gameObject.name +", Other:" + mInstance.gameObject.name ) );
            return;
        }

        mInstance = this;

        playerControllers = new List<PlayerController>();
        potentialMonstersByTime = new Dictionary<int, float>();
    }
Beispiel #33
0
    void Awake()
    {
        if( mInstance != null )
        {
            Debug.LogError( string.Format( "Only one instance of PlayerAgent allowed! Destroying:" + gameObject.name +", Other:" + mInstance.gameObject.name ) );
            Destroy( gameObject );
            return;
        }

        mInstance = this;

        ballObjects = new List<GameObject>();
        tallObjects = new List<GameObject>();

        toggles = new List<GameObject>();
        players = new List<GameObject>();

        activePlayers = new bool[4];
    }