Inheritance: MonoBehaviour
Ejemplo n.º 1
1
 // Use this for initialization
 void Start()
 {
     gameMaster = Camera.main.GetComponent<GameMaster> ();
     playerControl = Camera.main.GetComponent<PlayerControl> ();
     stats = Camera.main.GetComponent<Statistics> ();
     source = Camera.main.GetComponent<AudioSource> ();
 }
Ejemplo n.º 2
0
 void Awake()
 {
     // Setting up the references.
     mousePosition = new Vector3 (0, 0, 0);
     anim = transform.root.gameObject.GetComponent<Animator>();
     playerCtrl = transform.root.GetComponent<PlayerControl>();
 }
Ejemplo n.º 3
0
	void Start () {
		input = GameObject.FindWithTag ("InputControl").GetComponent<InputControl> ();
		master = GameObject.Find ("LaserWheel").GetComponent<LaserWheel> ();
		player = GameObject.FindWithTag ("Player").GetComponent<PlayerControl> ();
		line = gameObject.GetComponent<LineRenderer> ();
		line.enabled = false;
	}
Ejemplo n.º 4
0
 private void ActivatedByPlayer(PlayerControl aPlayerControl)
 {
     m_UsedByPlayer = true;
     ToggleObject(m_UsedByPlayer);
     // call some function on player which tells it what to make visible
     aPlayerControl.SetItemVisibility(ItemID);
 }
 /// <summary>
 /// 进入游戏关卡后,点击游戏开始的start按钮
 /// </summary>
 void Start()
 {
     startBackground = GameObject.Find("startBackground");
  
     Gplayer = GameObject.Find("Player");
     Splayer = Gplayer.GetComponent<PlayerControl>();
 }
Ejemplo n.º 6
0
    void Awake()
    {

        // Setting up references.
        groundCheck = transform.Find("groundCheck");
        anim = GetComponent<Animator>();

        bazooka = GameObject.FindGameObjectWithTag("bazooka2");
        facingRight = true;

        sgn = 1;
        time = 30;
        move = 20;
        idle = 0;

        obj = GameObject.Find("hero");
        script = obj.GetComponent<PlayerControl>();
        cnt = script.sgn;

        startt = bazooka.transform.localEulerAngles;
        bazooka.transform.Rotate(-180, 0, 0);
        end = bazooka.transform.localEulerAngles;

        bazooka.transform.Rotate(180, 0, 0);
    }
Ejemplo n.º 7
0
 // Use this for initialization
 void Start()
 {
     this.touchControl = new TouchControl(isTouchDevice);
     this.playerControl = new PlayerControl(this);
     this.target = GameObject.FindGameObjectWithTag("Target");
     this.UIControl = this.GetComponent<UIControl>();
 }
Ejemplo n.º 8
0
    //private bool destroyed = false;

    void Start(){
        soundManager = gameObject.GetComponentInChildren<SoundManager>();

        energy = maxEnergy;
        score = FindObjectOfType(typeof(ScoreKeeper)) as ScoreKeeper;

        playerControl = gameObject.GetComponentInChildren<PlayerControl>();
        playerGUI = gameObject.GetComponentInChildren<PlayerGUI>();
        playerHealth = gameObject.GetComponentInChildren<PlayerHealth>();
        thrust = gameObject.GetComponentInChildren<Thrust>();
        
        shield = gameObject.AddComponent<Shield>() as Shield;
        shield.PDelegate = this;


        foreach(Weapon weapon in gameObject.GetComponentsInChildren(typeof(IWeapon))){
            if(weapon.gameObject.name == "Left weapon"){
                leftWeapon = weapon;
                leftWeapon.soundManager = soundManager;
            }else if(weapon.gameObject.name == "Right weapon"){
                rightWeapon = weapon;
                rightWeapon.soundManager = soundManager;
            }
        }
        StartCoroutine("RegenerateEnergy");
    }
Ejemplo n.º 9
0
 void Start()
 {
     playerControl = GameObject.FindGameObjectWithTag(TagManager.PLAYER).GetComponent<PlayerControl>();
     vomit = GameObject.FindGameObjectWithTag("Vomit").GetComponent<ParticleSystem>();
     switcher = gameObject.GetComponent<CameraSwitcher>();
     audio.clip = vomitSound;
 }
Ejemplo n.º 10
0
    // Update is called once per frame
    void Update()
    {
        if(player == null)
        {
            var players = FindObjectsOfType<PlayerControl>();
            player = players.FirstOrDefault(x => (int)x.PlayerIndex == PlayerIndex);

        }

        if(player != null)
        {
            var damageable = player.GetComponent<Damageable>();
            var health = Mathf.Clamp(damageable.Health / damageable.StartingHealth, 0, 1);
            healthBar.localScale = new Vector3(health, 1, 1);

            if(player.CurrentWeapon == null)
                weaponLabel.text = "";
            else
            {
                weaponLabel.text = player.CurrentWeapon.GetPickupName();
                var ammo = player.CurrentWeapon.GetAmmoCount();
                if(ammo > -1)
                    weaponLabel.text += " " + ammo;
            }

            score.text = GameState.Players[player.PlayerIndex].RoundScore.ToString();
        }
    }
Ejemplo n.º 11
0
	public PlayerParty(PlayerControl control)
	{
		Members = new List<HumanCharacter>();
		_playerControl = control;


	}
Ejemplo n.º 12
0
 void Awake()
 {
     // Setting the current health when the player first spawns.
     currentHealth = startingHealth;
     playerControlScript = GetComponent<PlayerControl> ();
     godMode = false;
 }
Ejemplo n.º 13
0
    private PlayerControl playerCtrl; // Reference to the PlayerControl script.

    #endregion Fields

    #region Methods

    void Awake()
    {
        // Setting up the references.
        playerCtrl = transform.parent.GetComponent<PlayerControl>();
        Rigidbody2D bulletInstance = Instantiate(ammo, transform.position, Quaternion.Euler(new Vector3(0,0,0))) as Rigidbody2D;
        bulletInstance.velocity = new Vector2(speed, 0);
    }
Ejemplo n.º 14
0
 // Update is called once per frame
 public virtual void Update()
 {
     if (player == null)
     {
         player = GameObject.FindGameObjectWithTag("Player").GetComponent<PlayerControl>();
     }
 }
Ejemplo n.º 15
0
 void EndingCutscene()
 {
     //setup
     cutsceneActivated = false;
     //Get the horizontal extent of the camera
     horzExtent = Camera.main.orthographicSize * Screen.width / Screen.height;
     //Get the glow objects on items
     itemsGlow = GameObject.FindGameObjectsWithTag ("ParticleGlow");
     //Find the light bulb
     bulb = GameObject.Find ("LightBulb_NOT_lit_1");
     //Find the glow attached to the bulb
     bulbGlow = GameObject.Find ("LightBulbParticleGlow");
     //Get the color of the glow
     if (itemsGlow.Length > 1)
     {
         defaultGlowColor = itemsGlow[itemsGlow.Length - 1].GetComponent<ParticleSystem>().startColor;
     }
     player = GameObject.FindGameObjectWithTag("Player");
     cam = Camera.main.gameObject;
     pause = Camera.main.GetComponent<PauseScript>();
     pause.busy = true;
     //prevent player from moving until end of cutscene
     playerScript = player.GetComponent<PlayerControl>();
     playerScript.normalSpeed = 0f;
     // Figure out where the left wall is so the camera's panning can stop there
     wallMargin = wall.transform.position.x + wallOffset;
     StartCoroutine(_Cutscene());
 }
Ejemplo n.º 16
0
 void Awake()
 {
     player = GameObject.FindGameObjectWithTag (Tags.player);
             relDistance = player.transform.position.y - transform.position.y;
             playerControl = player.GetComponent<PlayerControl> ();
             playerOriPos = player.transform.position;
 }
Ejemplo n.º 17
0
    // Use this for initialization
    void Start()
    {
        if (MoveSpeed > 1)
            MoveSpeed = 1;

        _playerControl = GetComponent<PlayerControl>();
    }
 // Use this for initialization
 void Start()
 {
     anim = GetComponent<Animator>();
     playerScript = GetComponent<PlayerControl>();
     leftAmmo = ammo;
     ammoText = GameObject.FindWithTag("AmmoText").GetComponent<GUIText>();
 }
Ejemplo n.º 19
0
	public override void Setup(GameObject player) {
		this.player = player;
		playerControl = player.GetComponent<PlayerControl> ();
		originalJump = playerControl.jumpSpeed;
		originalMoveSpeed = playerControl.airControl;
		activationStatus = player.GetComponent<PlayerNotification> ();
	}
Ejemplo n.º 20
0
	public void ToClient(SocketIOEvent e){
		Debug.Log(string.Format("[name: {0}, data: {1}]", e.name, e.data));
		Debug.Log (e.data ["msg"].ToString().Trim());
		playercontrolobject = GameObject.Find ("__GameManager");
		_PlayerControl = playercontrolobject.GetComponent<PlayerControl> ();
		//_PlayerControl.TakeInput (e.data ["msg"].ToString().Trim('"'));
	}
    // Update is called once per frame
    void Update()
    {
        if(player == null)
                player = GameObject.FindGameObjectWithTag("Player").GetComponent<PlayerControl>();

            sprite.color = new Color(sprite.color.r, sprite.color.g, sprite.color.b, (float)player.getCurrentHealth() / 100f);
    }
Ejemplo n.º 22
0
 void Awake()
 {
     // Setting up the references.
     anim = transform.root.gameObject.GetComponent<Animator>();
     playerCtrl = transform.root.GetComponent<PlayerControl>();
     rocket = rocketGO.rigidbody2D;
 }
Ejemplo n.º 23
0
 // Use this for initialization
 void Start()
 {
     player = GameObject.Find("Player");
     playerScript = player.GetComponent<PlayerControl> ();
     pickedUp = false;
     //canThrow = true;
 }
Ejemplo n.º 24
0
	void Awake()
	{
		// Setting up the references.
		anim = this.GetComponentInParent<Animator>();
		playerCtrl = this.GetComponentInParent<PlayerControl>();
		rgbody = this.GetComponentInParent<Rigidbody2D> ();
	}
Ejemplo n.º 25
0
    private void Awake()
    {
        // Master
        MasterView viewMaster = Instantiate( masterView );
        viewMaster.Initialize( gameSetting.masterSetting );
        Master master = new Master( viewMaster );
        MasterAIControl masterControl = new MasterAIControl( master );

        // AI
        List<AIControl> AIControlList = new List<AIControl>();
        List<Character> AICharacter = new List<Character>();
        for ( int i = 0; i < AINumber; ++i )
        {
            CharacterView view = Instantiate( characterPrefab );
            view.Initialize( gameSetting.characterSetting );
            Character character = new Character( view );
            AIControl aiControl = new AIControl( gameSetting.AIControlSetting, character, master );
            AIControlList.Add( aiControl );
            AICharacter.Add( character );
        }

        // Player
        CharacterView playerView = Instantiate( characterPrefab );
        playerView.Initialize( gameSetting.characterSetting );
        Character player = new Character( playerView );
        PlayerControl playerControl = new PlayerControl( player, AICharacter );

        GameTime gameTime = new GameTime();
        controllerManager = new ControllerManager(playerControl, AIControlList, masterControl);
        gameManager = new GameManager( gameTime, controllerManager, player, AICharacter, master );

        successPanel.SetGameTime( gameTime );
    }
Ejemplo n.º 26
0
 public StateWallmasterChasing(Wallmaster _w, PlayerControl _p, SpriteRenderer _renderer, Sprite[] _animation) {
     w = _w;
     p = _p;
     rb = w.GetComponent<Rigidbody>();
     renderer = _renderer;
     animation = _animation;
 }
Ejemplo n.º 27
0
    public void StartSpeech(GameObject initiator)
    {
        if (showingText)
        {
            return;
        }

        if (randomizeTexts)
        {
            textIndex = Random.Range(0, texts.Length - 1);
        }

        if (initiator.CompareTag(playerTag))
        {
            playerControl = initiator.GetComponent<PlayerControl>();
            playerControl.freezeInput = true;
            speech.SetActive(true);

            showingText = true;
            skipUpdate = true;
            textAdvancer = initiator.GetComponent<TextAdvancer>();

            DrawText();
        }
    }
Ejemplo n.º 28
0
	void Update () 
	{
		if(mGen == null)
			mGen = FindObjectOfType<MazeGenerator>();
		else if(m == null)
		{
			m = mGen.currentMaze();
		}
		else if(pControl == null)
		{
			GameObject g = GameObject.FindGameObjectWithTag("MyPlayer");
			if(g != null)
				pControl = g.GetComponent<PlayerControl>();
		}
		else
		{
			pOffset = pixelOffset();
			cellDim = cellDimenstions();
			icon.rectTransform.sizeDelta = new Vector2(cellDimenstions().x, cellDimenstions().y);
			icon.transform.localEulerAngles = new Vector3(0,0,-pControl.transform.localEulerAngles.y + 90);
			Vector2 pPos = pControl.pos();
			float x = pixelOffset().x + (cellDimenstions().x*pPos.x) + (cellDimenstions().x/2);
			float y = pixelOffset().y + (cellDimenstions().y*pPos.y) + (cellDimenstions().x/2);
			Vector2 v = new Vector2(x,y);
			GetComponent<RectTransform>().anchoredPosition = v;
		}
	}
Ejemplo n.º 29
0
 void MyStart()
 {
     myRigid2D = this.GetComponent<Rigidbody2D>();
     GameObject player = GameObject.FindWithTag("Player");
     playCon = player.GetComponent<PlayerControl>();
     anim = this.GetComponent<Animator>();
 }
Ejemplo n.º 30
0
 // Use this for initialization
 void Start()
 {
     playerControl = Camera.main.GetComponent<PlayerControl> ();
     source = Camera.main.GetComponent<AudioSource> ();
     gameMaster = Camera.main.GetComponent<GameMaster> ();
     timer = 45;
 }
Ejemplo n.º 31
0
 void Awake()
 {
     // Setting up the reference.
     playerControl = GameObject.FindGameObjectWithTag("Player").GetComponent <PlayerControl>();
     _guiText      = GetComponent <Text> ();
 }
Ejemplo n.º 32
0
 // Start is called before the first frame update
 void Start()
 {
     //playerCtrl = GameObject.Find("hero").GetComponent<PlayerControl>();
     playerCtrl = transform.parent.GetComponent <PlayerControl>(); //找父类的组件
     audio      = GetComponent <AudioSource>();                    //获取声音
 }
Ejemplo n.º 33
0
 public void CrucioBlind(PlayerControl target)
 {
     System.Console.WriteLine("Blinding " + target.Data.PlayerName);
     Reactor.Coroutines.Start(CoBlindPlayer(target));
 }
Ejemplo n.º 34
0
 public void InvisPlayer(PlayerControl target)
 {
     Reactor.Coroutines.Start(CoInvisPlayer(target));
 }
Ejemplo n.º 35
0
        public System.Collections.IEnumerator CoControlPlayer(PlayerControl controller, PlayerControl target)
        {
            DateTime now = DateTime.UtcNow;

            ControlKillUsed = false;

            Instance.ModdedPlayerById(target.PlayerId).ControllerOverride =
                Instance.ModdedPlayerById(controller.PlayerId);

            ((Bellatrix)Instance.ModdedPlayerById(controller.PlayerId).Role).MindControlledPlayer =
                Instance.ModdedPlayerById(target.PlayerId);

            ImportantTextTask durationText = new ImportantTextTask();

            if (controller.AmOwner)
            {
                Camera.main.GetComponent <FollowerCamera>().Target      = target;
                Camera.main.GetComponent <FollowerCamera>().shakeAmount = 0;
                durationText = TaskInfoHandler.Instance.AddNewItem(1, $"{TaskInfoHandler.Instance.GetRoleHexColor(controller)}You are mind-controlling \"{target.Data.PlayerName}\"! {Config.ImperioDuration}s remaining</color></color>");
            }

            target.moveable     = true;
            controller.moveable = true;

            if (target.AmOwner || controller.AmOwner)
            {
                PlayerControl.LocalPlayer.MyPhysics.body.velocity = new Vector2(0, 0);
            }

            while (true)
            {
                if (target.Data.IsDead ||
                    MeetingHud.Instance ||
                    AmongUsClient.Instance.GameState != InnerNetClient.GameStates.Started ||
                    now.AddSeconds(Config.ImperioDuration) < DateTime.UtcNow)
                {
                    if (target.AmOwner)
                    {
                        target.moveable = true;
                    }
                    else if (controller.AmOwner)
                    {
                        TaskInfoHandler.Instance.RemoveItem(durationText);
                        controller.moveable = true;
                        Camera.main.GetComponent <FollowerCamera>().Target = controller;
                        controller.myLight.transform.position = controller.transform.position;
                        PlayerControl.LocalPlayer.SetKillTimer(PlayerControl.GameOptions.KillCooldown);
                    }
                    Instance.ModdedPlayerById(target.PlayerId).ControllerOverride = null;
                    ((Bellatrix)Instance.ModdedPlayerById(controller.PlayerId).Role).MindControlledPlayer = null;
                    yield break;
                }

                if (controller.AmOwner || target.AmOwner)
                {
                    if (Minigame.Instance)
                    {
                        Minigame.Instance.Close();
                    }
                    PlayerControl.LocalPlayer.moveable = false;
                    if (controller.AmOwner)
                    {
                        durationText.Text =
                            $"{TaskInfoHandler.Instance.GetRoleHexColor(controller)}You are mind-controlling \"{target.Data.PlayerName}\"! {Math.Ceiling(Config.ImperioDuration - (float) (DateTime.UtcNow - now).TotalSeconds)}s remaining</color></color>";
                        controller.myLight.transform.position = target.transform.position;
                        HudManager.Instance.KillButton.SetCoolDown(0f, PlayerControl.GameOptions.KillCooldown);
                        if (ControlKillUsed)
                        {
                            HudManager.Instance.KillButton.SetTarget(null);
                        }
                        else
                        {
                            HudManager.Instance.KillButton.SetTarget(target.FindClosestTarget());
                        }
                    }
                }

                yield return(null);
            }
        }
Ejemplo n.º 36
0
    private void RewardPlayer(int amount)
    {
        PlayerControl playerScript = FindObjectOfType <PlayerControl>();

        playerScript.healthCollect(1);
    }
Ejemplo n.º 37
0
 public static void clearAndReload()
 {
     spy = null;
     impostorsCanKillAnyone = CustomOptionHolder.spyImpostorsCanKillAnyone.getBool();
 }
Ejemplo n.º 38
0
 // Use this for initialization
 void Start()
 {
     playerControl = GameObject.FindWithTag("Player").GetComponent <PlayerControl>();
 }
Ejemplo n.º 39
0
 void Start()
 {
     thisTransform = this.transform;
     playerControl = player.GetComponent <PlayerControl>();
 }
Ejemplo n.º 40
0
 public abstract bool Interact(PlayerControl player);
Ejemplo n.º 41
0
 void Start()
 {
     pl = transform.root.GetComponent <PlayerControl>();
 }
Ejemplo n.º 42
0
 public static void clearAndReload()
 {
     engineer   = null;
     usedRepair = false;
 }
Ejemplo n.º 43
0
 private void Start()
 {
     m_playerController = FindObjectOfType <PlayerControl>();
 }
Ejemplo n.º 44
0
 public static void clearAndReload()
 {
     jester           = null;
     triggerJesterWin = false;
     canCallEmergency = CustomOptionHolder.jesterCanCallEmergency.getBool();
 }
Ejemplo n.º 45
0
 public static void clearAndReload()
 {
     mafioso = null;
 }
Ejemplo n.º 46
0
 public static void clearAndReload()
 {
     mayor = null;
 }
Ejemplo n.º 47
0
        public static void MurderPlayer(
            PlayerVoteArea voteArea,
            PlayerControl player,
            bool checkLover = true
            )
        {
            var hudManager = DestroyableSingleton <HudManager> .Instance;

            if (checkLover)
            {
                SoundManager.Instance.PlaySound(player.KillSfx, false, 0.8f);
                hudManager.KillOverlay.ShowKillAnimation(player.Data, player.Data);
            }
            var amOwner = player.AmOwner;

            if (amOwner)
            {
                hudManager.ShadowQuad.gameObject.SetActive(false);
                player.nameText.GetComponent <MeshRenderer>().material.SetInt("_Mask", 0);
                player.RpcSetScanner(false);
                ImportantTextTask importantTextTask = new GameObject("_Player").AddComponent <ImportantTextTask>();
                importantTextTask.transform.SetParent(AmongUsClient.Instance.transform, false);
                if (!PlayerControl.GameOptions.GhostsDoTasks)
                {
                    for (int i = 0; i < player.myTasks.Count; i++)
                    {
                        PlayerTask playerTask = player.myTasks.ToArray()[i];
                        playerTask.OnRemove();
                        Object.Destroy(playerTask.gameObject);
                    }

                    player.myTasks.Clear();
                    importantTextTask.Text = DestroyableSingleton <TranslationController> .Instance.GetString(
                        StringNames.GhostIgnoreTasks,
                        new UnhollowerBaseLib.Il2CppReferenceArray <Il2CppSystem.Object>(0)
                        );
                }
                else
                {
                    importantTextTask.Text = DestroyableSingleton <TranslationController> .Instance.GetString(
                        StringNames.GhostDoTasks,
                        new UnhollowerBaseLib.Il2CppReferenceArray <Il2CppSystem.Object>(0));
                }

                player.myTasks.Insert(0, importantTextTask);

                if (player.Is(RoleEnum.Swapper))
                {
                    var buttons = Role.GetRole <Swapper>(player).Buttons;
                    foreach (var button in buttons)
                    {
                        button.SetActive(false);
                        button.GetComponent <PassiveButton>().OnClick = new Button.ButtonClickedEvent();
                    }
                }
            }
            player.Die(DeathReason.Kill);
            if (checkLover && player.isLover() && CustomGameOptions.BothLoversDie)
            {
                MurderPlayer(Role.GetRole <Lover>(player).OtherLover.Player, false);
            }

            var meetingHud = MeetingHud.Instance;

            if (amOwner)
            {
                meetingHud.SetForegroundForDead();
            }
            var deadPlayer = new DeadPlayer
            {
                PlayerId = player.PlayerId,
                KillerId = player.PlayerId,
                KillTime = System.DateTime.UtcNow,
            };

            Murder.KilledPlayers.Add(deadPlayer);
            if (voteArea == null)
            {
                return;
            }
            if (voteArea.DidVote)
            {
                voteArea.UnsetVote();
            }
            voteArea.AmDead = true;
            voteArea.Overlay.gameObject.SetActive(true);
            voteArea.Overlay.color = Color.white;
            voteArea.XMark.gameObject.SetActive(true);
            voteArea.XMark.transform.localScale = Vector3.one;
            foreach (var playerVoteArea in meetingHud.playerStates)
            {
                if (playerVoteArea.VotedFor != player.PlayerId)
                {
                    continue;
                }
                playerVoteArea.UnsetVote();
                var voteAreaPlayer = Utils.PlayerById(playerVoteArea.TargetPlayerId);
                if (!voteAreaPlayer.AmOwner)
                {
                    continue;
                }
                meetingHud.ClearVote();
            }

            if (AmongUsClient.Instance.AmHost)
            {
                foreach (var role in Role.GetRoles(RoleEnum.Mayor))
                {
                    if (role is Mayor mayor)
                    {
                        if (role.Player == player)
                        {
                            mayor.ExtraVotes.Clear();
                        }
                        else
                        {
                            var votesRegained = mayor.ExtraVotes.RemoveAll(x => x == player.PlayerId);

                            if (mayor.Player == PlayerControl.LocalPlayer)
                            {
                                mayor.VoteBank += votesRegained;
                            }

                            var writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId,
                                                                                    (byte)CustomRPC.AddMayorVoteBank, SendOption.Reliable, -1);
                            writer.Write(mayor.Player.PlayerId);
                            writer.Write(votesRegained);
                            AmongUsClient.Instance.FinishRpcImmediately(writer);
                        }
                    }
                }
                meetingHud.CheckForEndVoting();
            }
        }
Ejemplo n.º 48
0
 public static void clearAndReload()
 {
     shifter       = null;
     currentTarget = null;
     futureShift   = null;
 }
Ejemplo n.º 49
0
 void Start()
 {
     coll   = GetComponent <BoxCollider2D>();
     player = GameObject.FindGameObjectWithTag("Player").GetComponent <PlayerControl>();
     anim   = GetComponent <Animator>();
 }
Ejemplo n.º 50
0
 public static void clearAndReload()
 {
     godfather = null;
 }
Ejemplo n.º 51
0
 public void ReadMemory()
 {
     Instance = Utils.FromBytes <PlayerControl>(Cheese.mem.ReadBytes(offset_str, Utils.SizeOf <PlayerControl>()));
 }
Ejemplo n.º 52
0
        /// <summary>
        /// Query and cache player data
        /// </summary>
        /// <param name="player">Player to load</param>
        /// <param name="control">Control to update</param>
        void LoadPlayer(PlayerParticipant player, PlayerControl control)
        {
            PlayerCache existing;
            var         ply = new PlayerCache();

            try
            {
                lock (PlayersCache)
                {
                    //Clear the cache every 1000 players to prevent crashing afk lobbies.
                    if (PlayersCache.Count > 1000)
                    {
                        PlayersCache.Clear();
                    }

                    //Does the player already exist in the cache?
                    if ((existing = PlayersCache.Find(p => p.Player != null && p.Player.Id == player.SummonerId)) == null)
                    {
                        PlayersCache.Add(ply);
                    }
                }

                //If another thread is loading the player data, lets wait for it to finish and use its data.
                if (existing != null)
                {
                    existing.LoadWait.WaitOne();
                    LoadPlayerUIFinish(existing, control);
                    return;
                }


                using (SimpleLogTimer.Start("Player query"))
                {
                    var entry = Recorder.GetPlayer(player.SummonerId);
                    ply.Player = entry ?? ply.Player;
                }

                using (SimpleLogTimer.Start("Stats query"))
                {
                    var cmd      = new PlayerCommands(Connection);
                    var summoner = cmd.GetPlayerByName(player.Name);
                    if (summoner != null)
                    {
                        ply.Summoner     = summoner;
                        ply.Stats        = cmd.RetrievePlayerStatsByAccountId(summoner.AccountId);
                        ply.RecentChamps = cmd.RetrieveTopPlayedChampions(summoner.AccountId, "CLASSIC");
                        ply.Games        = cmd.GetRecentGames(summoner.AccountId);
                    }
                    else
                    {
                        StaticLogger.Debug(string.Format("Player {0} not found", player.Name));
                        ply.LoadWait.Set();
                        return;
                    }
                }

                using (SimpleLogTimer.Start("Seen query"))
                {
                    if (SelfSummoner != null && SelfSummoner.SummonerId != ply.Summoner.SummonerId && ply.Games != null)
                    {
                        ply.SeenCount = ply.Games.GameStatistics.Count(pgs => pgs.FellowPlayers.Any(fp => fp.SummonerId == SelfSummoner.SummonerId));
                    }
                }

                ply.LoadWait.Set();
                LoadPlayerUIFinish(ply, control);
            }
            catch (Exception ex)
            {
                ply.LoadWait.Set();                 //
                StaticLogger.Warning(ex);
            }
        }
Ejemplo n.º 53
0
 private void Start()
 {
     player = FindObjectOfType <PlayerControl>();
     pos    = transform.position;
 }
Ejemplo n.º 54
0
    new void Update()
    {
        Debug.Log(turnBaseManager.phase);
        if (number_of_moving_turn <= 0)
        {
        }
        if (number_of_moving_turn > 0)
        {
            if (turnBaseManager.phase == 0)
            {
                if (true)
                {
                    turnBaseManager.turn_count++;
                    turn_maximum_count++;
                    diceManager.Roll(currentNumberOfDices);
                    if (currentNumberOfDices == 2 && diceManager.IsDouble())
                    {
                        if (turn_maximum_count >= turn_maximum_limit)
                        {
                            number_of_moving_turn = 1;
                            //code to fly to prison here

                            //
                            turnBaseManager.phase = 4;
                            return;
                        }
                        else
                        {
                            number_of_moving_turn++;
                        }
                        state_jail = 1;
                    }
                    Jump(state_jail * diceManager.dice_sum);
                    turnBaseManager.phase = 1;
                    ResetBuildStatus();
                }
                return;
            }

            if (turnBaseManager.phase == 1)
            {
                if (jump_delay_count < jump_delay)
                {
                    jump_delay_count   += Time.deltaTime;
                    transform.position += (next_position - prev_position) * Time.deltaTime / jump_delay;
                }
                else
                {
                    if (transform.position != next_position)
                    {
                        transform.position = next_position;
                        plotManager.GetComponent <PlotManager>().listPlot.Find(p => p.plotID == cur_location).ActivePlotPassByEffect(this);
                    }

                    if (dest_location != cur_location)
                    {
                        prev_position = SetNewPostition(cur_location);
                        cur_location += 1;
                        if (cur_location >= 32)
                        {
                            cur_location -= 32;
                        }
                        jump_delay_count = 0;
                        next_position    = SetNewPostition(cur_location);
                    }
                }

                //code when step on the plot
                if (transform.position == SetNewPostition(dest_location))
                {
                    turnBaseManager.phase = 2;
                }

                return;
            }

            if (turnBaseManager.phase == 2)
            {
                plotManager.GetComponent <PlotManager>().listPlot.Find(p => p.plotID == dest_location).ActivePlotEffect(this);
                turnBaseManager.phase = 4;

                return;
            }

            if (turnBaseManager.phase == 4)
            {
                number_of_moving_turn--;
                if (number_of_moving_turn > 0)
                {
                }
                else
                {
                    PlayerControl p = turnBaseManager.listPlayer.Dequeue();
                    p.number_of_moving_turn++;
                    turnBaseManager.listPlayer.Enqueue(p);
                    turn_maximum_count = 0;
                }
                turnBaseManager.phase = 0;
                return;
            }
        }
    }
Ejemplo n.º 55
0
 //Start is called before the first frame update
 void Start()
 {
     anim    = GetComponent <Animator>();
     control = GetComponent <PlayerControl>();
 }
Ejemplo n.º 56
0
    private Animator anim;                              // Reference to the Animator component.


    void Awake()
    {
        // Setting up the references.
        anim       = transform.root.gameObject.GetComponent <Animator>();
        playerCtrl = transform.root.GetComponent <PlayerControl>();
    }
Ejemplo n.º 57
0
 public void UseHourglass(PlayerControl player)
 {
     Reactor.Coroutines.Start(CoActivateHourglass(player));
 }
Ejemplo n.º 58
0
 public void DefensiveDuelist(PlayerControl player)
 {
     Reactor.Coroutines.Start(CoDefensiveDuelist(player));
 }
Ejemplo n.º 59
0
 public static void clearAndReload()
 {
     cleaner  = null;
     cooldown = CustomOptionHolder.janitorCooldown.getFloat();
 }
Ejemplo n.º 60
0
 private void Awake()
 {
     _anim     = GetComponent <Animator>();
     _player   = GetComponent <PlayerControl>();
     _playerRB = GetComponent <Rigidbody2D>();
 }