/// <summary>
 /// Cancel a player event
 /// </summary>
 /// <param name="e">The event that you want to cancel</param>
 /// <param name="p">The Player that event is related to</param>
 public static void CancelPlayerEvent(PlayerEvents e, Player p)
 {
     //TODO
     //Add some more events to be canceled
     switch (e)
     {
         case PlayerEvents.BlockChange:
             p.cancelBlock = true;
             break;
         case PlayerEvents.PlayerChat:
             p.cancelchat = true;
             break;
         case PlayerEvents.PlayerCommand:
             p.cancelcommand = true;
             break;
         case PlayerEvents.PlayerMove:
             p.cancelmove = true;
             break;
         case PlayerEvents.MYSQLSave:
             p.cancelmysql = true;
             break;
         case PlayerEvents.PlayerRankChange:
             Group.cancelrank = true;
             break;
         case PlayerEvents.MessageRecieve:
             p.cancelmessage = true;
             break;
     }
 }
        /// <summary>
        /// Constructor for handling warp events.
        /// </summary>
        /// <param name="Name">The name of the event.</param>
        /// <param name="Location">The game location that this event is located at.</param>
        /// <param name="Position">The x,y tile position of the event.</param>
        /// <param name="playerEvents">The events to occur when the player enters the warp tile before the warp.</param>
        /// <param name="WarpInfo">The information for warping the farmer.</param>
        public WarpEvent(string Name, GameLocation Location, Vector2 Position, PlayerEvents playerEvents, WarpInformation WarpInfo) : base(Name, Location, Position, playerEvents)
        {
            this.name         = Name;
            this.location     = Location;
            this.tilePosition = Position;
            this.playerEvents = playerEvents;
            this.warpInfo     = WarpInfo;

            this.doesInteractionNeedToRun = true;
        }
Exemple #3
0
        /// <inheritdoc />
        public override void OnDisabled()
        {
            MapEvents.UnsubscribeEvents();
            PlayerEvents.UnsubscribeEvents();
            ServerEvents.UnsubscribeEvents();

            harmony.UnpatchAll();

            base.OnDisabled();
        }
        public void CopyFrom(object rightComponent)
        {
            if (Events == null)
            {
                Events = new PlayerEvents();
            }
            var right = (RemoteEventsComponent)rightComponent;

            Events.CopyFrom(right.Events);
        }
Exemple #5
0
        /// <inheritdoc />
        public override void OnEnabled()
        {
            MapEvents.SubscribeEvents();
            PlayerEvents.SubscribeEvents();
            ServerEvents.SubscribeEvents();

            harmony = new Harmony($"build.scp457.{DateTime.UtcNow.Ticks}");
            harmony.PatchAll();

            base.OnEnabled();
        }
Exemple #6
0
        public ClientPlayer(string login, Guid id, Point position)
        {
            Size      = 32;
            _login    = login;
            _id       = id;
            Position  = position;
            ColorRect = GetRandomColor();
            stats     = new StatisticsPlayer(_login);

            PlayerEvents.GetInstance().Eat += EatFood;
        }
Exemple #7
0
 private void OnTriggerEnter(Collider other)
 {
     //if player collides obstacle, notify that game ended
     if (other.gameObject.tag == "Obstacle")
     {
         moving = false;
         //fire loose event
         PlayerEvents.FirePlayerDeath();
         PlayerEvents.PlaySound(SoundType.Asteroid);
     }
 }
Exemple #8
0
    private void TakeDamage(int d)
    {
        health--;
        health = Mathf.Max(0, health);
        PlayerEvents.Instance().InvokeUpdateHealth(health, maxHealth);

        if (health == 0)
        {
            PlayerEvents.Instance().InvokeDeath();
        }
    }
Exemple #9
0
 // Use this for initialization
 void Start()
 {
     if (!isLocalPlayer)
     {
         camera.enabled = false;
         return;
     }
     newposition     = transform.position;
     networkIdentity = GetComponent <NetworkIdentity>();
     playerEvents    = GetComponent <PlayerEvents>();
 }
 private void Awake()
 {
     instance         = this;
     playerEvents     = new PlayerEvents();
     evilPlayerEvents = new EvilPlayerEvents();
     enemyEvents      = new EnemyEvents();
     levelEvents      = new LevelEvents();
     enviromentEvents = new EnviromentEvents();
     weaponEvents     = new WeaponEvents();
     itemEvents       = new ItemEvents();
 }
Exemple #11
0
    private void UpdateLocomotion()
    {
        if (!PlayerEvents.HasEvent(PlayerEvents.InputEvents.MoveTo))
        {
            return;
        }

        Vector2Int position = (Vector2Int)PlayerEvents.GetEvent(PlayerEvents.InputEvents.MoveTo);

        m_PlayerComponent.MoveTo(position);
    }
Exemple #12
0
 void Awake()
 {
     if (Instance != null && Instance != this)
     {
         Destroy(this);
     }
     else
     {
         Instance = this;
     }
 }
Exemple #13
0
 void TeardownCallbacks()
 {
     gameActions.UI.Navigate.performed   -= HandleNavigation;
     gameActions.UI.Exit.performed       -= (ctx) => PlayerEvents.NotifyInventoryClose();
     gameActions.UI.Point.performed      -= (ctx) => Cursor.visible = true;
     PlayerEvents.OnInventoryOpened      -= ActivateInventory;
     PlayerEvents.OnInventoryClosed      -= DeactivateInventory;
     InventoryEvents.OnSlotHighlight     -= (slot) => SelectSlot(slot);
     InventoryEvents.OnSlotDehighlight   -= (slot) => DeselectSlot(slot);
     InventoryEvents.OnDetailedViewOpen  -= SuspendInventory;
     InventoryEvents.OnDetailedViewClose -= AwakeInventory;
 }
Exemple #14
0
        public void GameStopsOnGameOver()
        {
            var gameToTest = GenerateGame.GenerateAGame(8, 8, 5, 3, 0, 1);
            var dummyEvent = new PlayerEvents
            {
                GameOver = true
            };

            gameToTest.HandlePlayerEvent(this, dummyEvent);

            Assert.AreEqual(true, gameToTest.GameOver);
        }
Exemple #15
0
        public void GameContinues()
        {
            var gameToTest = GenerateGame.GenerateAGame(8, 8, 5, 3, 0, 1);
            var dummyEvent = new PlayerEvents
            {
                GameOver = false
            };

            gameToTest.HandlePlayerEvent(this, dummyEvent);

            Assert.AreEqual(false, gameToTest.GameOver);
        }
Exemple #16
0
 private void Update()
 {
     //update score if player pass obstacle
     if (transform.position.z < 0 && !obstaclePassed)
     {
         if (obstacle != null)
         {
             PlayerEvents.FireScoreUp(5, true);
             obstaclePassed = true;
         }
     }
 }
Exemple #17
0
 public BaseGameEvents()
 {
     Player   = new PlayerEvents();
     Time     = new TimeEvents();
     Monsters = new MonsterEvents();
     Entities = new EntityEvents();
     Flow     = new FlowEvents();
     Health   = new HPEvents();
     Battle   = new BattleEvents();
     Traps    = new TrapEvents();
     Blocks   = new BlockingEvents();
 }
Exemple #18
0
    private void DecreaseHealthCount()
    {
        _currentHealthCount--;

        if (_currentHealthCount >= 0)
        {
            HUDEvents.OnUpdateHealthHUD(_currentHealthCount);
        }
        else
        {
            PlayerEvents.OnPlayerDied();
        }
    }
    public void Death()
    {
        IsDead = true;
        playerController.PlayerAttackController.enabled   = false;
        playerController.PlayerInputController.enabled    = false;
        playerController.PlayerMovementController.enabled = false;
        playerController.PlayerAnimationController.SetIsDeadTrigger();

        PlayerEvents.OnPlayerDiedFunction();
        playerCollider.enabled = false;
        playerController.PlayerMovementController.Body.gravityScale = 0;
        //Do Death Things
    }
    //IDamagable Function
    public void TakeDamage(int damageValue)
    {
        playerCurrentHealth -= damageValue;

        PlayerEvents.CallPlayerTookDamage(damageValue);

        PlayerEvents.CallPlayerRemainingHP(playerCurrentHealth);

        if (playerCurrentHealth <= 0)
        {
            PlayerDies();
        }
    }
Exemple #21
0
    void OnTriggerEnter2D(Collider2D other)
    {
        if (other.CompareTag(TagHelper.PLAYER_TAG))
        {
            PlayerEvents.OnPlayerHitObstacleFunction();
        }

        if (other.CompareTag(TagHelper.OBSTACLE_DESTROY_TAG))
        {
            Obstacle parent = GetComponentInParent <Obstacle>();
            Destroy(parent.gameObject);
        }
    }
    // Use this for initialization
    void Start()
    {
        // Register listeners
        PlayerEvents.Instance().DespawnPlayer += SpawnPlayer;
        LevelEvents.Instance().SetCheckpoint  += SetCheckpoint;
        LevelEvents.Instance().ReachGoal      += WinLevel;

        // Level Manager logic
        currentCheckpoint = startPoint;

        player = Instantiate(PlayerPrefab);
        SpawnPlayer();
    }
        private void Initialize()
        {
            try
            {
                PlayerListener = new PlayerEvents(ActivityContext, ControlView);

                if (ActivityName != "FullScreen")
                {
                    SimpleExoPlayerView = ActivityContext.FindViewById <PlayerView>(Resource.Id.player_view);
                    SimpleExoPlayerView.SetControllerVisibilityListener(PlayerListener);
                    SimpleExoPlayerView.RequestFocus();

                    //Player initialize
                    ControlView    = SimpleExoPlayerView.FindViewById <PlayerControlView>(Resource.Id.exo_controller);
                    PlayerListener = new PlayerEvents(ActivityContext, ControlView);

                    MFullScreenIcon   = ControlView.FindViewById <ImageView>(Resource.Id.exo_fullscreen_icon);
                    MFullScreenButton = ControlView.FindViewById <FrameLayout>(Resource.Id.exo_fullscreen_button);

                    MainVideoFrameLayout = ActivityContext.FindViewById <FrameLayout>(Resource.Id.root);
                    MainVideoFrameLayout.SetOnClickListener(this);

                    switch (MFullScreenButton.HasOnClickListeners)
                    {
                    case false:
                        MFullScreenButton.SetOnClickListener(this);
                        break;
                    }
                }
                else
                {
                    FullscreenPlayerView = ActivityContext.FindViewById <PlayerView>(Resource.Id.player_view2);
                    ControlView          = FullscreenPlayerView.FindViewById <PlayerControlView>(Resource.Id.exo_controller);
                    PlayerListener       = new PlayerEvents(ActivityContext, ControlView);

                    MFullScreenIcon   = ControlView.FindViewById <ImageView>(Resource.Id.exo_fullscreen_icon);
                    MFullScreenButton = ControlView.FindViewById <FrameLayout>(Resource.Id.exo_fullscreen_button);

                    switch (MFullScreenButton.HasOnClickListeners)
                    {
                    case false:
                        MFullScreenButton.SetOnClickListener(this);
                        break;
                    }
                }
            }
            catch (Exception exception)
            {
                Methods.DisplayReportResultTrack(exception);
            }
        }
Exemple #24
0
        public void Interpolate(object left, object right, IInterpolationInfo interpolationInfo)
        {
            if (Events == null)
            {
                Events = new PlayerEvents();
            }

            if (Events.ServerTime != interpolationInfo.LeftServerTime)
            {
                var l = left as RemoteEventsComponent;
                Events.CopyFrom(l.Events);
                Events.HasHandler = false;
                Events.ServerTime = interpolationInfo.LeftServerTime;
            }
        }
    private void UpdateScore(int pointValue, int scrapValue)
    {
        // add point value to HUD
        playerCurrentScore += pointValue;
        playerCurrentScrap += scrapValue;

        if (playerCurrentScrap >= playerMaxScrap)
        {
            playerCurrentScrap = playerMaxScrap;
        }

        //Invoking Update Score/Scrap events to update the HUD
        PlayerEvents.CallUpdatePlayerScore(playerCurrentScore);
        PlayerEvents.CallUpdatePlayerScrap(playerCurrentScrap);
    }
Exemple #26
0
    // Update is called once per frame
    void Update()
    {
        if (Input.GetButtonDown("Shoot"))
        {
            animator.SetBool("Shooting", true);

            Vector3    pos = shootPoint.position;
            Quaternion rot = shootPoint.rotation * Quaternion.Euler(0F, 0F, transform.localScale.x < 0F ? 180F : 0F);

            PlayerEvents.Instance().InvokeSpawnShot(pos, rot);
        }
        else
        {
            animator.SetBool("Shooting", false);
        }
    }
Exemple #27
0
 public void Connect(params Player[] players)
 {
     if (players != null)
     {
         foreach (var player in players)
         {
             if (player != null)
             {
                 PlayerEvents.Add(new PlayerEvent()
                 {
                     Player = player
                 });
             }
         }
     }
 }
Exemple #28
0
    // Use this for initialization
    void Start()
    {
        PlayerEvents.Instance().SpawnShot   += SpawnBullet;
        PlayerEvents.Instance().DespawnShot += DespawnBullet;

        instances          = new List <GameObject>();
        instances.Capacity = startSize;

        for (int i = 0; i < startSize; i++)
        {
            GameObject instance = Instantiate(Prefab);
            instance.SetActive(false);

            instances.Add(instance);
        }
    }
Exemple #29
0
        public void DealDamage(int dmg, AbstractGameObject from)
        {
            UpgradedStats.Hp -= dmg;
            GameSoundManager.PlayOnTakeDamage(PrefabIndex);

            UnitBar_HTML.UpdateInfo(this);
            if (UpgradedStats.Hp > 0)
            {
                return;
            }

            KillSelf();
            QuestManager.OnKilling(from, this);
            UnitEvents.OnKilling(from, this);
            PlayerEvents.OnKilling(from, this);
        }
Exemple #30
0
        public void EnemyEatFood(FoodPoint foodPoint, int id, Guid id_player)
        {
            var food = FoodPoints.FirstOrDefault(i => i.ID == id);

            FoodPoints.Remove(food);
            FoodPoints.Add(foodPoint);

            var player = EnemyPlayers.FirstOrDefault(i => i.ID == id_player);

            if (player != null)
            {
                player.Size++;
                player.Score++;
            }

            PlayerEvents.GetInstance().EnemyEatFood();
        }
        // Start is called before the first frame update
        private void Start()
        {
            GameObject spawnedWeapon = Instantiate(Weapon, WeaponSocket.position, WeaponSocket.rotation);

            if (!spawnedWeapon)
            {
                return;
            }

            spawnedWeapon.transform.parent = WeaponSocket;
            EquippedWeapon = spawnedWeapon.GetComponent <WeaponComponent>();
            GripLocation   = EquippedWeapon.HandPosition;

            EquippedWeapon.Initialize(this, PlayerController.CrosshairComponent);

            PlayerEvents.Invoke_OnWeaponEquipped(EquippedWeapon);
        }
Exemple #32
0
 /// <summary>
 /// Check to see if a Player event is stopped
 /// </summary>
 /// <param name="e">The event to check</param>
 /// <param name="p">The Player that event is related to</param>
 /// <returns>This returns true or false, true means its stopped, false means its not</returns>
 public static bool IsPlayerEventCancled(PlayerEvents e, Player p)
 {
     switch (e)
     {
         case PlayerEvents.BlockChange:
             return p.cancelBlock;
         case PlayerEvents.PlayerChat:
             return p.cancelchat;
         case PlayerEvents.PlayerCommand:
             return p.cancelcommand;
         case PlayerEvents.PlayerMove:
             return p.cancelmove;
         case PlayerEvents.MYSQLSave:
             return p.cancelmysql;
         case PlayerEvents.PlayerRankChange:
             return Group.cancelrank;
         case PlayerEvents.MessageRecieve:
             return p.cancelmessage;
         default:
             return false;
     }
 }
 /// <summary>
 /// Cancel a Player event
 /// </summary>
 /// <param name="e">The event that you want to cancel</param>
 /// <param name="p">The Player that event is related to (null if not dealing with player event)</param>
 public static void CancelEvent(PlayerEvents e, Player p)
 {
     //TODO
     //Add some more events to be canceled
     switch (e)
     {
         case PlayerEvents.PlayerBlockChange:
             p.cancelBlock = true;
             break;
         case PlayerEvents.PlayerChat:
             p.cancelchat = true;
             break;
         case PlayerEvents.PlayerCommand:
             p.cancelcommand = true;
             break;
         case PlayerEvents.PlayerMove:
             p.cancelmove = true;
             break;
         case PlayerEvents.PlayerDig:
             p.canceldig = true;
             break;
     }
 }
 /// <summary>
 /// Check to see if a Player event is stopped
 /// </summary>
 /// <param name="e">The event to check</param>
 /// <param name="p">The Player that event is related to</param>
 /// <returns>This returns true or false, true means its stopped, false means its not</returns>
 public static bool IsPlayerEventCancled(PlayerEvents e, Player p)
Exemple #35
0
 /// <summary>
 /// Check to see if a Player event is stopped
 /// </summary>
 /// <param name="e">The event to check</param>
 /// <param name="p">The Player that event is related to</param>
 /// <returns>This returns true or false, true means its stopped, false means its not</returns>
 public static bool IsEventCancled(PlayerEvents e, Player p)
 {
     switch (e)
     {
         case PlayerEvents.PlayerChat:
             return p.cancelchat;
         case PlayerEvents.PlayerCommand:
             return p.cancelcommand;
         case PlayerEvents.PlayerMove:
             return p.cancelmove;
         case PlayerEvents.PlayerDig:
             return p.canceldig;
         case PlayerEvents.PlayerKick:
             return p.cancelkick;
         case PlayerEvents.WindowClose:
             return p.cancelclose;
         case PlayerEvents.EXPGain:
             return p.cancelgain;
         case PlayerEvents.EXPLost:
             return p.cancellost;
         case PlayerEvents.Respawn:
             return p.cancelrespawn;
         case PlayerEvents.EntityAttack:
             return p.cancelentityleft;
         case PlayerEvents.EntityRightClick:
             return p.cancelentityright;
         case PlayerEvents.BlockRightClick:
             return p.cancelblockright;
         case PlayerEvents.BlockLeftClick:
             return p.cancelblockleft;
         case PlayerEvents.BlockPlace:
             return p.cancelplace;
         case PlayerEvents.BlockBreak:
             return p.cancelbreak;
         case PlayerEvents.ItemUse:
             return p.cancelitemuse;
         default:
             return false;
     }
 }
Exemple #36
0
 /// <summary>
 /// Cancel a Player event
 /// </summary>
 /// <param name="e">The event that you want to cancel</param>
 /// <param name="p">The Player</param>
 public static void CancelEvent(PlayerEvents e, Player p)
 {
     //TODO
     //Add some more events to be canceled
     switch (e)
     {
         case PlayerEvents.PlayerChat:
             p.cancelchat = true;
             break;
         case PlayerEvents.PlayerCommand:
             p.cancelcommand = true;
             break;
         case PlayerEvents.PlayerMove:
             p.cancelmove = true;
             break;
         case PlayerEvents.PlayerDig:
             p.canceldig = true;
             break;
         case PlayerEvents.PlayerKick:
             p.cancelkick = true;
             break;
         case PlayerEvents.EXPGain:
             p.cancelgain = true;
             break;
         case PlayerEvents.EXPLost:
             p.cancellost = true;
             break;
         case PlayerEvents.WindowClose:
             p.cancelclose = true;
             break;
         case PlayerEvents.Respawn:
             p.cancelrespawn = true;
             break;
         case PlayerEvents.EntityAttack:
             p.cancelentityleft = true;
             break;
         case PlayerEvents.EntityRightClick:
             p.cancelentityright = true;
             break;
         case PlayerEvents.BlockRightClick:
             p.cancelblockright = true;
             break;
         case PlayerEvents.BlockLeftClick:
             p.cancelblockleft = true;
             break;
         case PlayerEvents.BlockPlace:
             p.cancelplace = true;
             break;
         case PlayerEvents.BlockBreak:
             p.cancelbreak = true;
             break;
         case PlayerEvents.ItemUse:
             p.cancelitemuse = true;
             break;
     }
 }
 /// <summary>
 /// Check to see if a Player event is stopped
 /// </summary>
 /// <param name="e">The event to check</param>
 /// <param name="p">The Player that event is related to</param>
 /// <returns>This returns true or false, true means its stopped, false means its not</returns>
 public static bool IsEventCancled(PlayerEvents e, Player p)
 {
     switch (e)
     {
         case PlayerEvents.PlayerBlockChange:
             return p.cancelBlock;
         case PlayerEvents.PlayerChat:
             return p.cancelchat;
         case PlayerEvents.PlayerCommand:
             return p.cancelcommand;
         case PlayerEvents.PlayerMove:
             return p.cancelmove;
         case PlayerEvents.PlayerDig:
             return p.canceldig;
         default:
             return false;
     }
 }