Inheritance: MonoBehaviour
Esempio n. 1
0
    // Use this for initialization
    void Start()
    {
        //countdown = transform.parent.parent.GetComponent<Countdown>();

        countdown = transform.parent.GetComponent<Countdown>();

        renderer = GetComponent<Renderer>();
        material = renderer.material;

        if (red) {
            material.SetColor("_EmissionColor", Color.grey);
            myColor = Color.red;
            signal = Countdown.signal.RED;
        }
        if (yellow) {
            material.SetColor("_EmissionColor", Color.grey);
            myColor = Color.yellow;
            signal = Countdown.signal.YELLOW;
        }
        if (green) {
            material.SetColor("_EmissionColor", Color.grey);
            myColor = Color.green;
            signal = Countdown.signal.GREEN;
        }
        material.SetFloat("_EmissionScaleUI", 0.1f);
    }
    private IEnumerator Move()
    {
        var countdown = new Countdown(0);

        while (true)
        {
            var settings = settingsArray.RandomElement();
            var element = settings.elements.RandomElement();
            
            countdown.Reset(settings.waitingTimeBetween.Random);
            while (!countdown.Update())
                yield return null;

            var strength = element.movementStrength.Random;
            var curve = element.movementCurve;
            countdown.Reset(element.movementTime.Random);

            var direction = MathUtil.RandomSign;

            while (!countdown.Update())
            {
                transform.SetLocalRotationEuler(z: curve.Evaluate(countdown.Percent) * strength * direction);
                yield return null;
            }

            transform.SetLocalRotationEuler(z: 0);
        }
    }
Esempio n. 3
0
	// Use this for initialization
	void Awake () {
        im = GetComponent<Image>();
        txt = GetComponent<Text>();
        i = text_sequence.Length; // Starts paused

        sngl = this;
	}
Esempio n. 4
0
 public void StoppedBecomesTrueAfterTimeHasPassed_InTwoSteps()
 {
     Countdown c = new Countdown(10);
       c.Tick(8);
       c.Tick(3);
       Assert.IsTrue(c.Stopped);
 }
Esempio n. 5
0
 // Use this for initialization
 void Start()
 {
     countdown = GameObject.Find("TrafficLight").GetComponent<Countdown>();
     countdownText = GetComponent<Text>();
     countdownText.text = "3";
     countdownText.fontSize = fontSize;
 }
Esempio n. 6
0
    void Start()
    {

        countdown = GetComponentInParent<Countdown>();
        button = GetComponent<Button>();

        timeLeft = 4;
    }
Esempio n. 7
0
    protected override void Awake()
    {
        base.Awake();

        nextChangeCountdown = new Countdown(0);

        ChooseTurnDelta();
    }
 void Awake()
 {
     mCountdown = FindObjectOfType<Countdown> ();
     mRecordingPlayer = FindObjectOfType<RecordingPlayer> ();
     mDialogueManager = FindObjectOfType<DialogueManager> ();
     mNetworkManager = FindObjectOfType<NetworkManager> ();
     mScreen = GameObject.FindGameObjectWithTag ("Screen");
     mViewerChart = FindObjectOfType<ViewerChart> ();
 }
Esempio n. 9
0
	void Start () {
        
        countdown = GetComponentInParent<Countdown>();
        
        button = GetComponentInChildren<Button>();
        text = button.GetComponentInChildren<Text>();
       
        timeLeft = 4;
	}
    int mFingerId = -1; // the ID of the finger that's steering

    void Start() {
        mLevelController = LevelController.GetComponent<LevelController>();
        mStats = GameManager.Instance.Progress.CurPilotStats;
        mShieldLeft = mStats.ShieldPoints;
        mFireCountdown = new Countdown(false, mStats.FireCooldown);
        UpdateAim();
        UpdateShield();
        UnlockRankBasedAchievements();
    }
 /// <summary>
 /// Sets the objects.
 /// </summary>
 /// 
 /// May migrate the win/lose gameobject to be a child of PlayerUI. Will need to change logic in countdown for this to work. 
 private void setObjects()
 {
     playerOne = GameObject.FindGameObjectWithTag("PlayerOne").GetComponent<Player>();
     playerTwo = GameObject.FindGameObjectWithTag("PlayerTwo").GetComponent<Player>();
     playerOneMessageUI = GameObject.FindGameObjectWithTag("PlayerOneUI").transform.GetChild(2).gameObject;
     playerTwoMessageUI = GameObject.FindGameObjectWithTag("PlayerTwoUI").transform.GetChild(2).gameObject;
     countDown = GameObject.FindGameObjectWithTag("Countdown").GetComponent<Countdown>();
     playAgain = GameObject.FindGameObjectWithTag("PlayAgain");
 }
 protected override void Awake()
 {
     base.Awake();
     audioSource = GetComponent<AudioSource>();
     resetVisualsCountdown = new Countdown(() => Callback.Routines.FireAndForgetRoutine(clearHitVisuals, stunTime, this), this);
     rend = GetComponent<MeshRenderer>();
     mat = rend.material = Instantiate(rend.material);
     mat.SetFloat("_MaxRadius", radius);
     rend.enabled = false;
 }
Esempio n. 13
0
 public void countdownTest()
 {
     Countdown countdown = new Countdown();
     int[] cd = countdown.countdown(4);
     Assert.AreEqual(cd.Length, 5);
     Assert.AreEqual(cd[0], 4);
     Assert.AreEqual(cd[1], 3);
     Assert.AreEqual(cd[2], 2);
     Assert.AreEqual(cd[3], 1);
     Assert.AreEqual(cd[4], 0);
 }
Esempio n. 14
0
    protected virtual void Awake()
    {
        pond = Pond.Instance;
        vehicle = GetComponentInParent<Vehicle>();
        entity = vehicle.GetComponent<Entity>();

        if (randomWeightChangingDelay.To > 0)
        {
            randomWeightChangingCountdown = new Countdown(0);
        }
        ChooseRandomWeightFactor();
    }
Esempio n. 15
0
    void Awake()
    {
        if (Instance == null)
        {
            Instance = this;
        }
        else if(Instance != this)
        {
            Instance.Start ();
            Destroy(gameObject);
        }

        DontDestroyOnLoad (gameObject);
    }
    private void Start()
    {
        if (settings == null)
        {
            Destroy(this);
            return;
        }

        speed = MathUtil.RandomOnUnitCircle * settings.startSpeed.Random;

        startPosition = transform.position;

        pickAccelerationCountdown = new Countdown(0);
        PickAcceleration();
    }
Esempio n. 17
0
    void Start()
    {
        AudioSource[] sources = GetComponents<AudioSource>();
        mainSong = sources[0];

        time = 0;
        waveStartTime = restDuration;
        waveCounter = 1;
        countdown = GameObject.Find("GameStuff").GetComponent<Countdown>();
        countdown.SetCountdownDuration(countdownDuration);
        roadManager = GameObject.Find("RoadManager").GetComponent<RoadManager>();
        lastPlayerNode = roadManager.playerNode;
        status = Status.Rest;
        initFov = Camera.main.fov;

        StartCoroutine(StartSongDelay(5));
    }
Esempio n. 18
0
    IEnumerator StartCDBeforeFight()
    {
        GameManager.instance.gamestate = GameManager.GameState.beforePlay;
        float timer = 5;
        while (m_second >= 0)
        {
            timer += Time.deltaTime * 500;
            yield return new WaitForSeconds(1f);
            if(m_second == 3)
            {
                
                text.CrossFadeAlpha(1f, 0f, false);
                text.CrossFadeAlpha(0.1f, 0.9f, false);
            }
            else if (m_second == 2)
            {
                text.CrossFadeAlpha(1f, 0f, false);
                text.CrossFadeAlpha(0.1f, 0.9f, false);
            }
            else if (m_second == 1)
            {
                text.CrossFadeAlpha(1f, 0f, false);
                text.CrossFadeAlpha(0.1f, 0.9f, false);
            }
            text.fontSize += Mathf.RoundToInt(timer);
            text.text = m_second.ToString();
            alpha = GetComponent<CanvasGroup>().alpha;
            m_second--;

        }
        text.CrossFadeAlpha(1f, 0.2f, false);
        
        text.text = "FIGHT";
        text.color = Color.red;
        if (text.text == "FIGHT")
        {
            text.CrossFadeAlpha(1f, 0f, false);
            text.CrossFadeAlpha(0f, 1f, false);
        }
        ready = true;
        yield return new WaitForSeconds(0.5f);
        GameManager.instance.gamestate = GameManager.GameState.playing;
    }
    protected override void Awake()
    {
        base.Awake();
        resetVisualsCountdown = new Countdown(() => Callback.Routines.FireAndForgetRoutine(clearHitVisuals, actualStunTime, this), this);
        meshFilter = GetComponent<MeshFilter>();
        meshRenderer = GetComponent<MeshRenderer>();
        sfx = GetComponent<AudioSource>();

        //create our mesh to represent the firing arc
        Mesh arcMesh = new Mesh();
        Assert.IsTrue(numArcPoints >= 0);
        Vector3[] verticies = new Vector3[numArcPoints + 3];
        Vector2[] uvs = new Vector2[verticies.Length];
        int[] triangles = new int[3 * (verticies.Length - 2)];

        //index zero is our centerpoint
        uvs[0] = Vector2.zero;

        verticies = generateArcVertices(initialArcAngle, initialArcLength);

        for(int i = 0; i <= numArcPoints + 1; i++)
        {
            float lerpValue = (float)i / (numArcPoints + 1);
            float uvAngle = lerpValue * Mathf.PI / 2;
            uvs[i + 1] = uvAngle.RadToVector2();
        }

        for (int i = 0; i < verticies.Length - 2; i++)
        {
            int triangleIndex = 3 * i;
            triangles[triangleIndex + 0] = 0;
            triangles[triangleIndex + 1] = i + 1;
            triangles[triangleIndex + 2] = i + 2;
        }

        meshFilter.mesh = arcMesh;
        arcMesh.vertices = verticies;
        arcMesh.uv = uvs;
        arcMesh.triangles = triangles;
    }
Esempio n. 20
0
        bool canView(Countdown c)
        {
            var chnl = c.GetChannel();

            return(chnl.GetUserAsync(Context.User.Id).Result != null);
        }
Esempio n. 21
0
 void Awake()
 {
     instance = this;
 }
Esempio n. 22
0
        static void Main(string[] args)
        {
            //1

            /*
             * int[] arr = {4,8,12,16,20,24,2,6,10 };
             * //int[] arr = null;
             * long EuclidtimeElapsed=0, SteintimeElapsed=0;
             *
             * try
             * {
             *  int multiEuclidGCD = CalcGCD.Calc(CalcGCD.multiEuclidGCD, out EuclidtimeElapsed, arr);
             *  Console.WriteLine("Euclid's algorithm result: {0}; Timer result: {1}", multiEuclidGCD, EuclidtimeElapsed);
             * }
             * catch (NullReferenceException e)
             * {
             *  Console.WriteLine(e);
             * }
             *
             * try
             * {
             *  int multiSteinGCD = CalcGCD.Calc(CalcGCD.multiSteinGCD,out SteintimeElapsed, arr);
             *  Console.WriteLine("Stein's algorithm result: {0}; Timer result: {1}", multiSteinGCD, SteintimeElapsed);
             *
             * }
             * catch (NullReferenceException e)
             * {
             *  Console.WriteLine(e);
             * }
             */
            //Task2

            /*
             * int[,] array = { { 26, 22, 14 }, { 23, 5, 13 }, { 44, 8, 11 } };
             * Console.WriteLine("Input array");
             * BubbleSortTask.Display(array);
             *
             * SumSort ss = new SumSort(true);
             * Sorter sorter = new Sorter(ss);
             *
             * Console.WriteLine("\r\nIn order of decreasing sums of elements of rows of the matrix");
             * sorter.ChangeSortType(new SumSort(false));
             * array = sorter.Sort(array);
             * BubbleSortTask.Display(array);
             *
             * Console.WriteLine("\r\nIn order of increasing sums of elements of rows of the matrix");
             * sorter.ChangeSortType(new SumSort(true));
             * array = sorter.Sort(array);
             * BubbleSortTask.Display(array);
             *
             * Console.WriteLine("\r\nIn order of decreasing max element of rows of the matrix");
             * sorter.ChangeSortType(new MaxSort(false));
             * array = sorter.Sort(array);
             * BubbleSortTask.Display(array);
             *
             * Console.WriteLine("\r\nIn order of increasing max element of rows of the matrix");
             * sorter.ChangeSortType(new MaxSort(true));
             * array = sorter.Sort(array);
             * BubbleSortTask.Display(array);
             *
             * Console.WriteLine("\r\nIn order of decreasing min element of rows of the matrix");
             * sorter.ChangeSortType(new MinSort(false));
             * array = sorter.Sort(array);
             * BubbleSortTask.Display(array);
             *
             * Console.WriteLine("\r\nIn order of increasing min element of rows of the matrix");
             * sorter.ChangeSortType(new MinSort(true));
             * array = sorter.Sort(array);
             * BubbleSortTask.Display(array);
             * Console.ReadKey();
             */
            //3

            var msgManager = new Countdown();

            var listener = new Listener();

            listener.Register(msgManager);
            msgManager.SendNewMsg("Hi", 3000);
            listener.Unregister(msgManager);

            Console.WriteLine();

            var listener2 = new Listener2();

            listener2.Register(msgManager);
            msgManager.SendNewMsg("Hi there", 2000);
            listener2.Unregister(msgManager);

            Console.ReadLine();
        }
    private void Start()
    {
        errorRetryCountdown = new Countdown(5f);

        Connect();
    }
Esempio n. 24
0
	void Start () {
        countdown = GetComponent<Countdown>();
	}
Esempio n. 25
0
 public MyTripCountdownViewModel()
 {
     _countdown = new Countdown();
 }
Esempio n. 26
0
        /// <summary>
        /// Place the duelist in the arena and start the countdown
        /// </summary>
        private void StartRound()
        {
            m_RoundStart = true;

            m_Duelist1.MoveToWorld(m_Stone.DuelLoc1, m_Stone.ArenaMap);
            m_Duelist1.Paralyzed = true;

            m_Duelist2.MoveToWorld(m_Stone.DuelLoc2, m_Stone.ArenaMap);
            m_Duelist2.Paralyzed = true;

            Countdown c = new Countdown(this);
            c.Start();
        }
Esempio n. 27
0
 public void DoesNotStopWithSmallTick()
 {
     Countdown c = new Countdown(10);
       c.Tick(1);
       Assert.IsFalse(c.Stopped);
 }
Esempio n. 28
0
        // Token: 0x060013FE RID: 5118 RVA: 0x0001E6FC File Offset: 0x0001D6FC
        protected override WorkflowElement CreateBody()
        {
            StateGraph stateGraph = new StateGraph(string.Format("OpponentPursuit: {0}", base.Entrant.Opponent.OpponentName));
            State      state      = new State("initial");
            State      state2     = new State("countdown");
            State      state3     = new State("inpursuit");
            State      state4     = new State("cooldown");
            State      state5     = new State("busted");
            State      state6     = new State("evaded");
            State      state7     = new State("post");

            new State("aborted");
            State state8 = new State("done");

            GameCore.Activities.Entrant.Components.CloseOnReceive <OnPursuitEngaged> activity  = new GameCore.Activities.Entrant.Components.CloseOnReceive <OnPursuitEngaged>(base.InstancedEvent, base.Entrant, Ports.Gameplay);
            GameCore.Activities.Components.CloseOnReceive <OnPursuitBusted>          activity2 = new GameCore.Activities.Components.CloseOnReceive <OnPursuitBusted>(Ports.Gameplay);
            EntrantFinished      activity3 = new EntrantFinished(base.InstancedEvent, base.Entrant, -8193);
            EntrantFinished      activity4 = new EntrantFinished(base.InstancedEvent, base.Entrant, 8202);
            OnUpdateTick         activity5 = new OnUpdateTick(base.InstancedEvent, base.Entrant);
            Conclude             item      = new Conclude(base.InstancedEvent, base.Entrant);
            FlushCops            item2     = new FlushCops();
            LoadBehavior         item3     = new LoadBehavior(base.InstancedEvent, base.Entrant, "BEHAVIOR_GAMEPLAY_PURSUIT", "PursuitMonitorBehavior");
            EntrantLoaded        item4     = new EntrantLoaded(base.InstancedEvent, base.Entrant, "Entrants.Loading");
            PrepareScoringMethod item5     = new PrepareScoringMethod(base.InstancedEvent, base.Entrant);
            EnableLoadingScreen  item6     = new EnableLoadingScreen(false);
            HandleTutorial       item7     = new HandleTutorial(base.InstancedEvent, base.Entrant, TutorialSource.kTutorialSource_Pursuit);
            Launch item8 = new Launch(base.InstancedEvent, base.Entrant);
            AssignPursuitEscalation item9 = new AssignPursuitEscalation(base.Event.EventDef.PursuitEscalation().GetKey());

            state.EnterActivity.Activities.Add(item3);
            state.Transitions.Add(new Transition("countdown"));
            LockEntrant                 item10    = new LockEntrant(base.InstancedEvent, base.Entrant, true);
            EnableKeyboard              item11    = new EnableKeyboard(true);
            FlushTraffic                item12    = new FlushTraffic();
            LoadBlackBoards             item13    = new LoadBlackBoards(base.Event, BlackBoardFlag.kBlackBoardFlag_Running);
            Countdown                   activity6 = new Countdown(base.InstancedEvent, base.Entrant);
            TryPerfectLaunch            item14    = new TryPerfectLaunch(base.InstancedEvent, base.Entrant);
            LockEntrant                 item15    = new LockEntrant(base.InstancedEvent, base.Entrant, false);
            LaunchPursuitByOpponentHeat item16    = new LaunchPursuitByOpponentHeat(base.InstancedEvent, base.Entrant);

            state2.EnterActivity.Activities.Add(item10);
            state2.EnterActivity.Activities.Add(item9);
            state2.EnterActivity.Activities.Add(item5);
            state2.EnterActivity.Activities.Add(item4);
            state2.EnterActivity.Activities.Add(item11);
            state2.EnterActivity.Activities.Add(item12);
            state2.EnterActivity.Activities.Add(item6);
            state2.EnterActivity.Activities.Add(item13);
            state2.EnterActivity.Activities.Add(item7);
            state2.Transitions.Add(new Transition("inpursuit", activity6));
            state2.ExitActivity.Activities.Add(item14);
            state2.ExitActivity.Activities.Add(item8);
            state2.ExitActivity.Activities.Add(item15);
            state2.ExitActivity.Activities.Add(item16);
            VisualEffect           item17 = new VisualEffect(EffectType.ENTER_COP_PURSUIT);
            EnablePointsOfInterest item18 = new EnablePointsOfInterest(4291711951u, true);

            GameCore.Activities.Entrant.Components.CloseOnReceive <OnPursuitCooldown> activity7 = new GameCore.Activities.Entrant.Components.CloseOnReceive <OnPursuitCooldown>(base.InstancedEvent, base.Entrant, Ports.Gameplay);
            EnablePointsOfInterest item19 = new EnablePointsOfInterest(4291711951u, false);

            state3.EnterActivity.Activities.Add(item17);
            state3.EnterActivity.Activities.Add(item18);
            state3.Transitions.Add(new Transition("cooldown", activity7));
            state3.Transitions.Add(new Transition("busted", activity2));
            state3.Transitions.Add(new Transition("done", activity4));
            state3.Transitions.Add(new Transition(activity5));
            state3.ExitActivity.Activities.Add(item19);
            EnablePointsOfInterest item20 = new EnablePointsOfInterest(3470858927u, true);

            GameCore.Activities.Entrant.Components.CloseOnReceive <OnPursuitEvaded> activity8 = new GameCore.Activities.Entrant.Components.CloseOnReceive <OnPursuitEvaded>(base.InstancedEvent, base.Entrant, Ports.Gameplay);
            EnablePointsOfInterest item21 = new EnablePointsOfInterest(3470858927u, false);
            HandleTutorial         item22 = new HandleTutorial(base.InstancedEvent, base.Entrant, TutorialSource.kTutorialSource_PursuitCooldown);

            state4.EnterActivity.Activities.Add(item20);
            state4.EnterActivity.Activities.Add(item22);
            state4.Transitions.Add(new Transition("inpursuit", activity));
            state4.Transitions.Add(new Transition("evaded", activity8));
            state4.Transitions.Add(new Transition("busted", activity2));
            state4.Transitions.Add(new Transition("done", activity4));
            state4.Transitions.Add(new Transition(activity5));
            state4.ExitActivity.Activities.Add(item21);
            FinishEntrant activity9 = new FinishEntrant(base.InstancedEvent, base.Entrant, FinishReason.Evaded);
            HardwareBlinkingEffectEntrant item23 = new HardwareBlinkingEffectEntrant(base.InstancedEvent, base.Entrant, 4278216447u, 3.8f, 0.4f);

            state6.EnterActivity.Activities.Add(item23);
            state6.Transitions.Add(new Transition("post", activity3));
            state6.Transitions.Add(new Transition("done", activity4));
            state6.Transitions.Add(new Transition(activity9));
            state6.ExitActivity.Activities.Add(item);
            FinishEntrant activity10             = new FinishEntrant(base.InstancedEvent, base.Entrant, FinishReason.Busted);
            HardwareBlinkingEffectEntrant item24 = new HardwareBlinkingEffectEntrant(base.InstancedEvent, base.Entrant, 4294901760u, 3f, 0.1f);
            Bust item25 = new Bust(base.InstancedEvent, base.Entrant);

            state5.EnterActivity.Activities.Add(item24);
            state5.Transitions.Add(new Transition("post", activity3));
            state5.Transitions.Add(new Transition("done", activity4));
            state5.Transitions.Add(new Transition(activity10));
            state5.ExitActivity.Activities.Add(item25);
            OverrideVehicleControl item26     = new OverrideVehicleControl(base.Entrant.Opponent.Vehicle, OverrideVehicleControl.Control.Stop);
            ReleaseBehavior        item27     = new ReleaseBehavior(base.InstancedEvent, base.Entrant, "BEHAVIOR_GAMEPLAY_PURSUIT");
            PostEventScreen        activity11 = new PostEventScreen(base.InstancedEvent, base.Entrant, Ports.Gameplay);
            ChangeBlackBoard       item28     = new ChangeBlackBoard(BlackBoardChannel.kBlackBoard_Audio, 3114481865u);
            ChangeBlackBoard       item29     = new ChangeBlackBoard(BlackBoardChannel.kBlackBoard_AI, 331198907u);

            state7.EnterActivity.Activities.Add(item28);
            state7.EnterActivity.Activities.Add(item29);
            state7.EnterActivity.Activities.Add(item26);
            state7.EnterActivity.Activities.Add(item2);
            state7.EnterActivity.Activities.Add(item12);
            state7.EnterActivity.Activities.Add(item27);
            state7.Transitions.Add(new Transition("done", activity11));
            OverrideVehicleControl item30 = new OverrideVehicleControl(base.Entrant.Opponent.Vehicle, OverrideVehicleControl.Control.Release);
            CleanupScoringMethod   item31 = new CleanupScoringMethod(base.InstancedEvent, base.Entrant);

            state8.EnterActivity.Activities.Add(item30);
            state8.EnterActivity.Activities.Add(item31);
            stateGraph.InitialState = "initial";
            stateGraph.DoneState    = "done";
            stateGraph.States.Add(state);
            stateGraph.States.Add(state2);
            stateGraph.States.Add(state3);
            stateGraph.States.Add(state4);
            stateGraph.States.Add(state5);
            stateGraph.States.Add(state6);
            stateGraph.States.Add(state7);
            stateGraph.States.Add(state8);
            return(stateGraph);
        }
Esempio n. 29
0
        public override void Assign(Room room)
        {
            AssignGeneralsForPlayers(room, out Dictionary <Player, List <string> > options);

            List <Interactivity> receivers = new List <Interactivity>();

            foreach (Player player in options.Keys)
            {
                player.SetTag("generals", JsonUntity.Object2Json(options[player]));
                List <string> args = new List <string>
                {
                    player.Name,
                    string.Empty,
                    JsonUntity.Object2Json(options[player]),
                    false.ToString(),
                    true.ToString(),
                    true.ToString()
                };
                Interactivity client = room.GetInteractivity(player);
                if (client != null && !receivers.Contains(client))
                {
                    client.CommandArgs = args;
                    receivers.Add(client);
                }
            }

            List <Player> players   = room.Players;
            Countdown     countdown = new Countdown
            {
                Max  = room.Setting.GetCommandTimeout(CommandType.S_COMMAND_CHOOSE_GENERAL, ProcessInstanceType.S_CLIENT_INSTANCE),
                Type = Countdown.CountdownType.S_COUNTDOWN_USE_SPECIFIED
            };

            room.NotifyMoveFocus(players, countdown);
            room.DoBroadcastRequest(receivers, CommandType.S_COMMAND_CHOOSE_GENERAL);
            room.DoBroadcastNotify(CommandType.S_COMMAND_UNKNOWN, new List <string> {
                false.ToString()
            });

            foreach (Player player in options.Keys)
            {
                player.RemoveTag("generals");
                if (!string.IsNullOrEmpty(player.General1))
                {
                    continue;
                }
                bool          success = true;
                Interactivity client  = room.GetInteractivity(player);
                List <string> reply   = client?.ClientReply;
                if (client == null || !client.IsClientResponseReady || reply == null || reply.Count == 0 || string.IsNullOrEmpty(reply[0]))
                {
                    success = false;
                }
                else
                {
                    string   generalName = reply[0];
                    string[] generals    = generalName.Split('+');
                    if (generals.Length != 2 || (!options[player].Contains(generals[0]) && room.GetClient(player).UserRight < 3) ||
                        (!options[player].Contains(generals[1]) && room.GetClient(player).UserRight < 3) ||
                        !SetPlayerGeneral(room, player, generals[0], true) ||
                        !SetPlayerGeneral(room, player, generals[1], false))
                    {
                        success = false;
                    }
                }
                if (!success)
                {
                    List <string> default_generals = GeneralSelctor.GeInstance().SelectGenerals(room, options[player]);
                    SetPlayerGeneral(room, player, default_generals[0], true);
                    SetPlayerGeneral(room, player, default_generals[1], false);
                }
            }

            foreach (Player player in players)
            {
                List <string> names = new List <string>();
                if (!string.IsNullOrEmpty(player.General1))
                {
                    string name = player.General1;
                    player.Kingdom = General.GetKingdom(Engine.GetGeneral(player.General1, room.Setting.GameMode).Kingdom[0]);
                    string role = Engine.GetMappedRole(player.Kingdom);
                    if (string.IsNullOrEmpty(role))
                    {
                        role = General.GetKingdom(Engine.GetGeneral(player.General1, room.Setting.GameMode).Kingdom[0]);
                    }
                    names.Add(name);
                    player.Role     = role;
                    player.General1 = "anjiang";
                    foreach (Client p in room.Clients)
                    {
                        if (p != room.GetClient(player))
                        {
                            room.NotifyProperty(p, player, "Kingdom", "god");
                        }
                    }
                    room.BroadcastProperty(player, "General1");
                    room.NotifyProperty(room.GetClient(player), player, "ActualGeneral1");
                    room.NotifyProperty(room.GetClient(player), player, "Kingdom");
                }

                if (!string.IsNullOrEmpty(player.General2))
                {
                    string name = player.General2;
                    names.Add(name);
                    player.General2 = "anjiang";
                    room.BroadcastProperty(player, "General2");
                    room.NotifyProperty(room.GetClient(player), player, "ActualGeneral2");
                }
                room.SetTag(player.Name, names);

                room.HandleUsedGeneral(names[0]);
                room.HandleUsedGeneral(names[1]);

                if (reserved.TryGetValue(player, out List <string> p_reserved) && (p_reserved.Contains(names[0]) || p_reserved.Contains(names[1])))
                {
                    LogMessage reserved_log = new LogMessage();
                    reserved_log.Type = "#reserved_pick";
                    reserved_log.From = player.Name;
                    room.SendLog(reserved_log);
                }

                if (!options[player].Contains(names[0]) || !options[player].Contains(names[1]))
                {
                    LogMessage log = new LogMessage();
                    log.Type = "#cheat_pick";
                    log.From = player.Name;
                    room.SendLog(log);
                }
            }

            //君主转换
            if (room.Setting.LordConvert)
            {
                room.AskForLordConvert();
            }

            foreach (Player player in players)
            {
                General general1 = Engine.GetGeneral(player.ActualGeneral1, room.Setting.GameMode);
                General general2 = Engine.GetGeneral(player.ActualGeneral2, room.Setting.GameMode);

                if (general1.CompanionWith(player.ActualGeneral2, Name))
                {
                    player.AddMark("CompanionEffect");
                }

                int max_hp = general1.GetMaxHpHead() + general2.GetMaxHpDeputy();
                player.SetMark("HalfMaxHpLeft", max_hp % 2);

                player.MaxHp = max_hp / 2;
                player.Hp    = player.MaxHp;

                room.BroadcastProperty(player, "MaxHp");
                room.BroadcastProperty(player, "Hp");
            }
        }
Esempio n. 30
0
 //------------------------------------------------------------------------/
 // Interface
 //------------------------------------------------------------------------/
 protected override void OnTaskStart(Agent agent)
 {
     this.timer = new Countdown(this.duration);
 }
Esempio n. 31
0
 void Start () {
     image = GetComponent<Image>();
     countdown = GetComponentInParent<Countdown>();
     image.enabled = false;
 }
 public abstract string GetNextMove(State state, Countdown countdown);
Esempio n. 33
0
        public override void Assign(Room room)
        {
            System.Threading.Thread.Sleep(1000);
            //先确定两边主公
            foreach (Player lord in room.Players)
            {
                if (lord.GetRoleEnum() == Player.PlayerRole.Lord)
                {
                    if (lord.Camp == Game3v3Camp.S_CAMP_COOL)
                    {
                        lord.General1 = lord.ActualGeneral1 = "caocao_jx";
                    }
                    else
                    {
                        lord.General1 = lord.ActualGeneral1 = "yuanshao";
                    }

                    General lord_gen = Engine.GetGeneral(lord.General1, room.Setting.GameMode);
                    lord.PlayerGender   = lord_gen.GeneralGender;
                    lord.Kingdom        = lord_gen.Kingdom;
                    lord.General1Showed = true;
                    room.BroadcastProperty(lord, "General1");
                    room.BroadcastProperty(lord, "PlayerGender");
                    room.NotifyProperty(room.GetClient(lord), lord, "ActualGeneral1");
                    room.BroadcastProperty(lord, "Kingdom");
                    room.BroadcastProperty(lord, "General1Showed");
                    foreach (string skill in Engine.GetGeneralSkills(lord.General1, Name, true))
                    {
                        room.AddPlayerSkill(lord, skill);
                        Skill s = Engine.GetSkill(skill);
                        if (s != null && s.SkillFrequency == Frequency.Limited && !string.IsNullOrEmpty(s.LimitMark))
                        {
                            room.SetPlayerMark(lord, s.LimitMark, 1);
                        }
                    }

                    room.SendPlayerSkillsToOthers(lord, true);

                    //技能预亮
                    lord.SetSkillsPreshowed("hd");
                    room.NotifyPlayerPreshow(lord);
                }
            }

            System.Threading.Thread.Sleep(1000);

            //为其余玩家分配武将
            List <string> generals = room.Generals, warms = new List <string>(), cools = new List <string>();

            generals.Remove("caocao_jx"); generals.Remove("yuanshao");
            foreach (string general in generals)
            {
                General gen = Engine.GetGeneral(general, room.Setting.GameMode);
                if (gen.Kingdom == "wei")
                {
                    cools.Add(general);
                }
                else
                {
                    warms.Add(general);
                }
            }
            Shuffle.shuffle(ref warms);
            Shuffle.shuffle(ref cools);

            Dictionary <Player, List <string> > options = new Dictionary <Player, List <string> >();

            foreach (Player player in room.Players)
            {
                if (player.GetRoleEnum() == Player.PlayerRole.Lord)
                {
                    continue;
                }
                List <string> choices = new List <string>();

                if (player.Camp == Game3v3Camp.S_CAMP_COOL)
                {
                    choices.Add(cools[0]);
                    cools.RemoveAt(0);
                    choices.Add(cools[0]);
                    cools.RemoveAt(0);
                }
                else
                {
                    choices.Add(warms[0]);
                    warms.RemoveAt(0);
                    choices.Add(warms[0]);
                    warms.RemoveAt(0);
                }

                options.Add(player, choices);
            }

            //玩家选将
            List <Client> receivers = new List <Client>();
            List <Player> players   = new List <Player>();

            foreach (Player player in options.Keys)
            {
                if (player.GetRoleEnum() == Player.PlayerRole.Lord)
                {
                    continue;
                }
                player.SetTag("generals", JsonUntity.Object2Json(options[player]));
                List <string> args = new List <string>
                {
                    player.Name,
                    string.Empty,
                    JsonUntity.Object2Json(options[player]),
                    true.ToString(),
                    true.ToString(),
                    false.ToString()
                };
                Client client = room.GetClient(player);
                if (client != null && !receivers.Contains(client))
                {
                    client.CommandArgs = args;
                    receivers.Add(client);
                }
                players.Add(player);
            }

            Countdown countdown = new Countdown
            {
                Max  = room.Setting.GetCommandTimeout(CommandType.S_COMMAND_CHOOSE_GENERAL, ProcessInstanceType.S_CLIENT_INSTANCE),
                Type = Countdown.CountdownType.S_COUNTDOWN_USE_SPECIFIED
            };

            room.NotifyMoveFocus(players, countdown);
            room.DoBroadcastRequest(receivers, CommandType.S_COMMAND_CHOOSE_GENERAL);
            room.DoBroadcastNotify(CommandType.S_COMMAND_UNKNOWN, new List <string> {
                false.ToString()
            });

            //按武将强度排序
            List <string> prefer_cools = new List <string> {
                "xunyou", "xunyu", "chengyu", "guojia", "liuye", "caoren", "guanyu_sp", "xuhuang", "zhangliao_jx",
                "hanhaoshihuan", "yujin", "caohong"
            };
            List <string> prefer_warms = new List <string> {
                "chunyuqiong", "xunchen", "shenpei", "liubei_gd", "chenlin_gd", "jvshou", "xuyou", "zhanghe_gd", "gaolan",
                "guotupangji", "tianfeng", "yanliangwenchou"
            };

            //给AI和超时的玩家自动选择武将
            foreach (Player player in options.Keys)
            {
                player.RemoveTag("generals");
                if (string.IsNullOrEmpty(player.General1))
                {
                    string        generalName = string.Empty;
                    List <string> reply       = room.GetClient(player)?.ClientReply;
                    bool          success     = true;
                    if (reply == null || reply.Count == 0 || string.IsNullOrEmpty(reply[0]))
                    {
                        success = false;
                    }
                    else
                    {
                        generalName = reply[0];
                    }

                    if (!success || (!options[player].Contains(Engine.GetMainGeneral(generalName)) && room.GetClient(player).UserRight < 3) ||
                        (player.Camp == Game3v3Camp.S_CAMP_COOL && Engine.GetGeneral(generalName, room.Setting.GameMode).Kingdom != "wei") ||
                        (player.Camp == Game3v3Camp.S_CAMP_WARM && Engine.GetGeneral(generalName, room.Setting.GameMode).Kingdom != "qun"))
                    {
                        if (player.Status == "bot")
                        {
                            List <string> prefers;
                            if (player.Camp == Game3v3Camp.S_CAMP_COOL)
                            {
                                prefers = prefer_cools;
                            }
                            else
                            {
                                prefers = prefer_warms;
                            }

                            options[player].Sort((x, y) => { return(prefers.IndexOf(x) < prefers.IndexOf(y) ? -1 : 1); });
                        }
                        generalName = options[player][0];
                    }
                    player.General1       = generalName;
                    player.ActualGeneral1 = generalName;
                    player.Kingdom        = Engine.GetGeneral(generalName, room.Setting.GameMode).Kingdom;
                    player.General1Showed = true;
                }

                room.BroadcastProperty(player, "General1");
                room.NotifyProperty(room.GetClient(player), player, "ActualGeneral1");
                room.BroadcastProperty(player, "Kingdom");
                room.BroadcastProperty(player, "General1Showed");
                player.PlayerGender = Engine.GetGeneral(player.General1, room.Setting.GameMode).GeneralGender;
                room.BroadcastProperty(player, "PlayerGender");

                player.SetSkillsPreshowed("hd");
                room.NotifyPlayerPreshow(player);
                List <string> names = new List <string> {
                    player.General1
                };
                room.SetTag(player.Name, names);
                room.HandleUsedGeneral(player.General1);
            }
        }
Esempio n. 34
0
        public void EnsureLoaded(Node manifest, string assemblyName, Stopwatch sw = null)
        {
            if (TargetFolder == null)
            {
                this.AcceptIssue(
                    new Issue("Applicaiton does not have IOPermission; Native dependencies for " + assemblyName +
                              " will not be downloaded if missing"));
                return;
            }
            string platform = IntPtr.Size == 8 ? "64" : "32";

            Queue <Dependency> q = new Queue <Dependency>();

            try {
                foreach (Node c in manifest.childrenByName("file"))
                {
                    string bitness = c.Attrs["bitness"];//Skip files with the wrong bitness
                    if (bitness != null && !bitness.Equals(platform, StringComparison.OrdinalIgnoreCase))
                    {
                        continue;
                    }

                    string name = c.Attrs["name"]; //Skip duplicate names
                    if (string.IsNullOrEmpty(name))
                    {
                        this.AcceptIssue(new Issues.Issue("Missing attribute 'name' in native dependency manifest for " + assemblyName, Issues.IssueSeverity.Warning));
                    }
                    if (filesVerified.Contains(name))
                    {
                        continue;
                    }

                    //What is the expected size? If none listed, any size will work.
                    int fileBytes = 0;
                    if (c.Attrs["fileBytes"] != null && !int.TryParse(c.Attrs["fileBytes"], System.Globalization.NumberStyles.Number, NumberFormatInfo.InvariantInfo, out fileBytes))
                    {
                        this.AcceptIssue(new Issues.Issue("Failed to parse fileBytes value " + c.Attrs["fileBytes"] + " in native dependency manifest for " + assemblyName, Issues.IssueSeverity.Warning));
                    }

                    //Download url?
                    string url = c.Attrs["url"];


                    string destPath = Path.Combine(TargetFolder, name);

                    long existingLength = 0;

                    //Does it already exist?
                    if (File.Exists(destPath))
                    {
                        if (fileBytes < 1)
                        {
                            filesVerified.Add(name);
                            continue;
                        }
                        else
                        {
                            existingLength = new FileInfo(destPath).Length;
                            if (existingLength == fileBytes)
                            {
                                filesVerified.Add(name);
                                continue;
                            }
                        }
                    }

                    var d = new Dependency()
                    {
                        Exists = existingLength > 0, Name = name, Url = url, DestPath = destPath, ExistingLength = existingLength, ExpectedLength = fileBytes, Client = new WebClient(), RequestingAssembly = assemblyName
                    };
                    q.Enqueue(d);
                }

                sw.Stop();
                if (sw.ElapsedMilliseconds > 100 && q.Count < 1)
                {
                    this.AcceptIssue(new Issues.Issue("Verifying native dependencies for " + assemblyName + " took " + sw.ElapsedMilliseconds + "ms.", Issues.IssueSeverity.Warning));
                }

                ServicePointManager.DefaultConnectionLimit = 1000; //Allow more than 2 simultaneous http requests.
                StringBuilder message = new StringBuilder();
                if (q.Count > 0)
                {
                    Stopwatch dsw = new Stopwatch();
                    dsw.Start();
                    using (var cd = new Countdown(q.Count)) {
                        foreach (var current in q.ToArray())
                        {
                            var d = current;
                            ThreadPool.QueueUserWorkItem(x => {
                                DownloadFile(d, message);
                                cd.Signal();
                            });
                        }
                        cd.Wait();
                    }
                    dsw.Stop();
                    this.AcceptIssue(new Issues.Issue("Some native dependencies for " + assemblyName + " were missing, but were downloaded successfully. This delayed startup time by " + (sw.ElapsedMilliseconds + dsw.ElapsedMilliseconds).ToString() + "ms.", message.ToString(), Issues.IssueSeverity.Warning));
                }
            } finally {
                foreach (Dependency d in q.ToArray())
                {
                    d.Client.Dispose();
                }
            }
        }
Esempio n. 35
0
 public void StoppedIsFalseFromBeginning()
 {
     Countdown c = new Countdown(10);
       Assert.IsFalse(c.Stopped);
 }
 void itemTimersAwake()
 {
     scoreMakerTimer = gameObject.AddComponent <Countdown> ();
     arrowTimer      = gameObject.AddComponent <Countdown> ();
     lockTimer       = gameObject.AddComponent <Countdown> ();
 }
Esempio n. 37
0
 protected override void Awake()
 {
     base.Awake();
     targetSearchingCountdown = Countdown.TimedCountdown(FindNewTarget, searchInterval, this);
 }
Esempio n. 38
0
 public Webcam(int CaptureIntervalMs)
 {
     CaptureCD = new Countdown(CaptureIntervalMs, false);
 }
Esempio n. 39
0
 public void BroadcastCountdownCreate(Countdown countdown) => Hub.Clients.All.broadcastCountdownCreate(countdown);
 private void Awake()
 {
     countdownRef = FindObjectOfType(typeof(Countdown)) as Countdown;
     //dangerSignRef = FindObjectOfType(typeof(DangerIdentifier)) as DangerIdentifier; //just drag into inspector
     lavaParticleRef = FindObjectsOfType <LavaParticlesIdentifier>();
 }
Esempio n. 41
0
        public override void Assign(Room room)
        {
            //确定身份
            Player lord = room.Players[0];

            lord.Role = "lord";
            room.BroadcastProperty(lord, "Role");

            List <string> roles = new List <string> {
                "loyalist", "rebel", "renegade"
            };

            if (room.Players.Count == 5)
            {
                roles.Add("rebel");
            }
            else if (room.Players.Count == 6)
            {
                roles.Add("rebel");
                roles.Add("rebel");
            }
            else if (room.Players.Count == 7)
            {
                roles.Add("loyalist");
                roles.Add("rebel");
                roles.Add("rebel");
            }
            else if (room.Players.Count == 8)
            {
                roles.Add("loyalist");
                roles.Add("rebel");
                roles.Add("rebel");
                roles.Add("rebel");
            }
            List <Player> all = new List <Player>(room.Players);

            all.Remove(lord);

            //点选内奸的玩家
            List <Player> to_choose = new List <Player>();

            foreach (Player p in room.Players)
            {
                if (p.GetRoleEnum() != PlayerRole.Lord && room.GetClient(p).RoleReserved == "renegade")
                {
                    to_choose.Add(p);
                }
            }

            if (to_choose.Count > 0)
            {
                List <string> renegades = roles.FindAll(t => t == "renegade");
                Shuffle.shuffle(ref to_choose);
                for (int i = 0; i < Math.Min(to_choose.Count, renegades.Count); i++)
                {
                    to_choose[i].Role = "renegade";
                    roles.Remove("renegade");
                    all.Remove(to_choose[i]);
                }
            }

            //点选忠臣的玩家
            to_choose.Clear();
            foreach (Player p in room.Players)
            {
                if (p.GetRoleEnum() != PlayerRole.Lord && room.GetClient(p).RoleReserved == "loyalist")
                {
                    to_choose.Add(p);
                }
            }

            if (to_choose.Count > 0)
            {
                List <string> loyalists = roles.FindAll(t => t == "loyalist");
                Shuffle.shuffle(ref to_choose);
                for (int i = 0; i < Math.Min(loyalists.Count, to_choose.Count); i++)
                {
                    to_choose[i].Role = "loyalist";
                    roles.Remove("loyalist");
                    all.Remove(to_choose[i]);
                }
            }
            //点选反贼的玩家
            to_choose.Clear();
            foreach (Player p in room.Players)
            {
                if (p.GetRoleEnum() != PlayerRole.Lord && room.GetClient(p).RoleReserved == "rebel")
                {
                    to_choose.Add(p);
                }
            }

            if (to_choose.Count > 0)
            {
                List <string> rebels = roles.FindAll(t => t == "rebel");
                Shuffle.shuffle(ref to_choose);
                for (int i = 0; i < Math.Min(rebels.Count, to_choose.Count); i++)
                {
                    to_choose[i].Role = "rebel";
                    roles.Remove("rebel");
                    all.Remove(to_choose[i]);
                }
            }

            //为剩余玩家随机身份
            if (roles.Count > 0)
            {
                Shuffle.shuffle(ref roles);
                for (int i = 0; i < all.Count; i++)
                {
                    all[i].Role = roles[i];
                }
            }

            //通知各玩家身份
            foreach (Player p in room.Players)
            {
                room.NotifyProperty(room.GetClient(p), p, "Role");
            }

            room.UpdateStateItem();

            Thread.Sleep(2500);

            AssignGeneralsForPlayers(room, out Dictionary <Player, List <string> > options);
            //主公选将
            string lord_general = room.AskForGeneral(lord, new List <string>(options[lord]), string.Empty, true, "gamerule", null, true);

            lord.General1       = lord_general;
            lord.ActualGeneral1 = lord_general;
            General lord_gen = Engine.GetGeneral(lord_general, room.Setting.GameMode);

            lord.PlayerGender   = lord_gen.GeneralGender;
            lord.Kingdom        = lord_gen.Kingdom;
            lord.General1Showed = true;
            room.BroadcastProperty(lord, "General1");
            room.BroadcastProperty(lord, "PlayerGender");
            room.NotifyProperty(room.GetClient(lord), lord, "ActualGeneral1");
            room.BroadcastProperty(lord, "Kingdom");
            room.BroadcastProperty(lord, "General1Showed");

            foreach (string skill in Engine.GetGeneralSkills(lord_general, Name, true))
            {
                room.AddPlayerSkill(lord, skill);
                Skill s = Engine.GetSkill(skill);
                if (skill != null && s.SkillFrequency == Frequency.Limited && !string.IsNullOrEmpty(s.LimitMark))
                {
                    room.SetPlayerMark(lord, s.LimitMark, 1);
                }
            }
            room.SendPlayerSkillsToOthers(lord, true);

            //技能预亮
            lord.SetSkillsPreshowed("hd");
            room.NotifyPlayerPreshow(lord);
            //主公神将选国籍
            string        choice  = "wei+qun+shu+wu";
            List <string> prompts = new List <string> {
                "@choose-kingdom"
            };

            if (lord.Kingdom == "god")
            {
                lord.Kingdom = room.AskForChoice(lord, "Kingdom", choice, prompts);
                room.BroadcastProperty(lord, "Kingdom");
            }

            //其他玩家选将
            List <Client> receivers = new List <Client>();
            List <Player> players   = new List <Player>();

            foreach (Player player in options.Keys)
            {
                if (player.GetRoleEnum() == PlayerRole.Lord)
                {
                    continue;
                }
                player.SetTag("generals", JsonUntity.Object2Json(options[player]));
                List <string> args = new List <string>
                {
                    player.Name,
                    string.Empty,
                    JsonUntity.Object2Json(options[player]),
                    true.ToString(),
                    true.ToString(),
                    false.ToString()
                };
                Client client = room.GetClient(player);
                if (client != null && !receivers.Contains(client))
                {
                    client.CommandArgs = args;
                    receivers.Add(client);
                }
                players.Add(player);
            }

            Countdown countdown = new Countdown
            {
                Max  = room.Setting.GetCommandTimeout(CommandType.S_COMMAND_CHOOSE_GENERAL, ProcessInstanceType.S_CLIENT_INSTANCE),
                Type = Countdown.CountdownType.S_COUNTDOWN_USE_SPECIFIED
            };

            room.NotifyMoveFocus(players, countdown);
            room.DoBroadcastRequest(receivers, CommandType.S_COMMAND_CHOOSE_GENERAL);
            room.DoBroadcastNotify(CommandType.S_COMMAND_UNKNOWN, new List <string> {
                false.ToString()
            });

            //给AI和超时的玩家自动选择武将
            foreach (Player player in options.Keys)
            {
                player.RemoveTag("generals");
                if (string.IsNullOrEmpty(player.General1))
                {
                    string        generalName = string.Empty;
                    Client        client      = room.GetClient(player);
                    List <string> reply       = client?.ClientReply;
                    bool          success     = true;
                    if (reply == null || reply.Count == 0 || string.IsNullOrEmpty(reply[0]))
                    {
                        success = false;
                    }
                    else
                    {
                        generalName = reply[0];
                    }

                    if (!success || (!options[player].Contains(Engine.GetMainGeneral(generalName)) && room.GetClient(player).UserRight < 3))
                    {
                        generalName = options[player][0];
                    }

                    player.General1       = generalName;
                    player.ActualGeneral1 = generalName;
                    player.Kingdom        = Engine.GetGeneral(generalName, room.Setting.GameMode).Kingdom;
                    player.General1Showed = true;
                }

                room.BroadcastProperty(player, "General1");
                room.NotifyProperty(room.GetClient(player), player, "ActualGeneral1");
                room.BroadcastProperty(player, "Kingdom");
                room.BroadcastProperty(player, "General1Showed");
                player.PlayerGender = Engine.GetGeneral(player.General1, room.Setting.GameMode).GeneralGender;
                room.BroadcastProperty(player, "PlayerGender");

                player.SetSkillsPreshowed("hd");
                room.NotifyPlayerPreshow(player);
                List <string> names = new List <string> {
                    player.General1
                };
                room.SetTag(player.Name, names);
                room.HandleUsedGeneral(player.General1);
            }

            //非主公神将选国籍
            receivers.Clear();
            players.Clear();
            foreach (Player player in room.Players)
            {
                if (player.Kingdom != "god")
                {
                    continue;
                }
                List <string> args = new List <string>
                {
                    player.Name,
                    "Kingdom",
                    choice,
                    JsonUntity.Object2Json(prompts)
                };
                Client client = room.GetClient(player);
                if (client != null && !receivers.Contains(client))
                {
                    client.CommandArgs = args;
                    receivers.Add(client);
                }
                players.Add(player);
            }

            countdown = new Countdown
            {
                Max  = room.Setting.GetCommandTimeout(CommandType.S_COMMAND_MULTIPLE_CHOICE, ProcessInstanceType.S_CLIENT_INSTANCE),
                Type = Countdown.CountdownType.S_COUNTDOWN_USE_SPECIFIED
            };
            room.NotifyMoveFocus(players, countdown);
            room.DoBroadcastRequest(receivers, CommandType.S_COMMAND_MULTIPLE_CHOICE);
            room.DoBroadcastNotify(CommandType.S_COMMAND_UNKNOWN, new List <string> {
                false.ToString()
            });

            foreach (Player player in players)
            {
                string        answer      = string.Empty;
                List <string> clientReply = room.GetClient(player).ClientReply;
                if (clientReply != null && clientReply.Count > 0)
                {
                    answer = clientReply[0];
                }
                List <string> choices = new List <string>(choice.Split('+'));

                if (string.IsNullOrEmpty(answer) || !choices.Contains(answer))
                {
                    Shuffle.shuffle(ref choices);
                    answer = choices[0];
                }
                player.Kingdom = answer;
                room.BroadcastProperty(player, "Kingdom");
            }
        }
Esempio n. 42
0
File: GameUI.cs Progetto: dvdfu/ld47
 void Start()
 {
     shock = new Countdown(0.5f);
     shock.Finish();
     gameData.Reset();
 }
Esempio n. 43
0
        public void EnsureLoaded(Node manifest, string assemblyName, Stopwatch sw = null)
        {
            if (TargetFolder == null)
            {
                this.AcceptIssue(
                    new Issue("Applicaiton does not have IOPermission; Native dependencies for " + assemblyName +
                              " will not be downloaded if missing"));
                return;
            }
            string platform = IntPtr.Size == 8 ? "64" : "32";

            Queue<Dependency> q = new Queue<Dependency>();
            try {
                foreach (Node c in manifest.childrenByName("file")) {
                    string bitness = c.Attrs["bitness"];//Skip files with the wrong bitness
                    if (bitness != null && !bitness.Equals(platform, StringComparison.OrdinalIgnoreCase)) continue;

                    string name = c.Attrs["name"]; //Skip duplicate names
                    if (string.IsNullOrEmpty(name)) this.AcceptIssue(new Issues.Issue("Missing attribute 'name' in native dependency manifest for " + assemblyName, Issues.IssueSeverity.Warning));
                    if (filesVerified.Contains(name)) continue;

                    //What is the expected size? If none listed, any size will work.
                    int fileBytes = 0;
                    if (c.Attrs["fileBytes"] != null && !int.TryParse(c.Attrs["fileBytes"], System.Globalization.NumberStyles.Number, NumberFormatInfo.InvariantInfo, out fileBytes))
                        this.AcceptIssue(new Issues.Issue("Failed to parse fileBytes value " + c.Attrs["fileBytes"] + " in native dependency manifest for " + assemblyName, Issues.IssueSeverity.Warning));

                    //Download url?
                    string url = c.Attrs["url"];

                    string destPath = Path.Combine(TargetFolder, name);

                    long existingLength = 0;

                    //Does it already exist?
                    if (File.Exists(destPath)) {
                        if (fileBytes < 1) {
                            filesVerified.Add(name);
                            continue;
                        } else {
                            existingLength = new FileInfo(destPath).Length;
                            if (existingLength == fileBytes) {
                                filesVerified.Add(name);
                                continue;
                            }
                        }
                    }

                    var d = new Dependency() { Exists = existingLength > 0, Name = name, Url = url, DestPath = destPath, ExistingLength = existingLength, ExpectedLength = fileBytes, Client = new WebClient(), RequestingAssembly =assemblyName };
                    q.Enqueue(d);
                }

                sw.Stop();
                if (sw.ElapsedMilliseconds > 100 && q.Count < 1) this.AcceptIssue(new Issues.Issue("Verifying native dependencies for " + assemblyName + " took " + sw.ElapsedMilliseconds + "ms.", Issues.IssueSeverity.Warning));

                ServicePointManager.DefaultConnectionLimit = 1000; //Allow more than 2 simultaneous http requests.
                StringBuilder message = new StringBuilder();
                if (q.Count > 0) {
                    Stopwatch dsw = new Stopwatch();
                    dsw.Start();
                    using (var cd = new Countdown(q.Count)) {
                        foreach (var current in q.ToArray()) {
                            var d = current;
                            ThreadPool.QueueUserWorkItem(x => {
                                DownloadFile(d, message);
                                cd.Signal();
                            });
                        }
                        cd.Wait();
                    }
                    dsw.Stop();
                    this.AcceptIssue(new Issues.Issue("Some native dependencies for " + assemblyName + " were missing, but were downloaded successfully. This delayed startup time by " + (sw.ElapsedMilliseconds + dsw.ElapsedMilliseconds).ToString() + "ms.", message.ToString(), Issues.IssueSeverity.Warning));

                }

            } finally {
                foreach (Dependency d in q.ToArray()) {
                    d.Client.Dispose();
                }
            }
        }
Esempio n. 44
0
 // Use this for initialization
 void Start()
 {
     cameraSize = this.gameObject.GetComponent <Camera>().orthographicSize;
     countdown  = GameObject.Find("Countdown").GetComponent <Countdown>();
 }
Esempio n. 45
0
 private void Awake()
 {
     instance = this;
     countdownText.gameObject.SetActive(false);
 }
Esempio n. 46
0
        public static void ReenableTimer()
        {
            Thread.Sleep(250);

            Countdown.Start();
        }
Esempio n. 47
0
        // Token: 0x060013F8 RID: 5112 RVA: 0x0001D2B4 File Offset: 0x0001C2B4
        protected override WorkflowElement CreateBody()
        {
            StateGraph stateGraph = new StateGraph(string.Format("OpponentNormal: {0}", base.Entrant.Opponent.OpponentName));
            State      state      = new State("initial");
            State      state2     = new State("countdown");
            State      state3     = new State("running");
            State      state4     = new State("raceover");
            State      state5     = new State("post");
            State      state6     = new State("paused");
            State      state7     = new State("aborted");
            State      state8     = new State("done");

            state.Transitions.Add(new Transition("countdown"));
            PrepareScoringMethod item     = new PrepareScoringMethod(base.InstancedEvent, base.Entrant);
            LockEntrant          item2    = new LockEntrant(base.InstancedEvent, base.Entrant, true);
            EntrantLoaded        item3    = new EntrantLoaded(base.InstancedEvent, base.Entrant, "Entrants.Loading");
            EnableKeyboard       item4    = new EnableKeyboard(true);
            EnableLoadingScreen  item5    = new EnableLoadingScreen(false);
            FlushTraffic         item6    = new FlushTraffic();
            FlushCops            item7    = new FlushCops();
            HandleTutorial       item8    = new HandleTutorial(base.InstancedEvent, base.Entrant, TutorialSource.kTutorialSource_Race);
            Countdown            activity = new Countdown(base.InstancedEvent, base.Entrant);
            TryPerfectLaunch     item9    = new TryPerfectLaunch(base.InstancedEvent, base.Entrant);
            LockEntrant          item10   = new LockEntrant(base.InstancedEvent, base.Entrant, false);

            GameCore.Workflow.Activities.WaitAll item11 = new GameCore.Workflow.Activities.WaitAll("Entrants.Countdown");
            SetSignal             item12    = new SetSignal("Entrants.Countdown");
            UnSetSignal           item13    = new UnSetSignal("Entrants.Countdown");
            Launch                item14    = new Launch(base.InstancedEvent, base.Entrant);
            RoutingTriggered      activity2 = new RoutingTriggered(base.InstancedEvent, base.Entrant, Ports.Gameplay);
            OnUpdateTick          activity3 = new OnUpdateTick(base.InstancedEvent, base.Entrant);
            EntrantInterupt       activity4 = new EntrantInterupt(base.InstancedEvent, base.Entrant, Ports.Gameplay, FinishReason.TimedOut);
            EntrantExtrapolate    activity5 = new EntrantExtrapolate(base.InstancedEvent, base.Entrant, Ports.Gameplay);
            EntrantDisconnected   activity6 = new EntrantDisconnected(base.InstancedEvent, base.Entrant);
            EntrantFinished       activity7 = new EntrantFinished(base.InstancedEvent, base.Entrant, -8193);
            EntrantFinished       activity8 = new EntrantFinished(base.InstancedEvent, base.Entrant, 8202);
            KillAllFlashers       item15    = new KillAllFlashers(base.InstancedEvent, base.Entrant);
            Conclude              item16    = new Conclude(base.InstancedEvent, base.Entrant);
            SortEntrants          item17    = new SortEntrants(base.InstancedEvent);
            ReportEntrantFinished item18    = new ReportEntrantFinished(base.InstancedEvent, base.Entrant);

            GameCore.Activities.Entrant.Components.SynchronizeOnReceive <OnTriggerEnter> activity9  = new GameCore.Activities.Entrant.Components.SynchronizeOnReceive <OnTriggerEnter>(base.InstancedEvent, base.Entrant, Ports.Gameplay);
            GameCore.Activities.Entrant.Components.SynchronizeOnReceive <OnTriggerExit>  activity10 = new GameCore.Activities.Entrant.Components.SynchronizeOnReceive <OnTriggerExit>(base.InstancedEvent, base.Entrant, Ports.Gameplay);
            VehicleSpeedBasedReset activity11 = new VehicleSpeedBasedReset(base.Entrant, 0.1f);
            LoadBlackBoards        item19     = new LoadBlackBoards(base.InstancedEvent, BlackBoardFlag.kBlackBoardFlag_Countdown);
            PauseDetected          activity12 = new PauseDetected(base.InstancedEvent);

            if (base.Entrant.Opponent is LocalHumanOpponent)
            {
                state2.EnterActivity.Activities.Add(item2);
                state2.EnterActivity.Activities.Add(item);
                state2.EnterActivity.Activities.Add(item3);
                state2.EnterActivity.Activities.Add(item4);
                state2.EnterActivity.Activities.Add(item6);
                state2.EnterActivity.Activities.Add(item7);
                state2.EnterActivity.Activities.Add(item5);
                state2.EnterActivity.Activities.Add(item8);
                state2.EnterActivity.Activities.Add(item19);
                state2.Transitions.Add(new Transition("running", activity));
                state2.Transitions.Add(new Transition("aborted", activity12));
                state2.ExitActivity.Activities.Add(item9);
                state2.ExitActivity.Activities.Add(item12);
                state2.ExitActivity.Activities.Add(item11);
                state2.ExitActivity.Activities.Add(item13);
                state2.ExitActivity.Activities.Add(item14);
            }
            else
            {
                state2.EnterActivity.Activities.Add(item2);
                state2.EnterActivity.Activities.Add(item);
                state2.EnterActivity.Activities.Add(item3);
                state2.EnterActivity.Activities.Add(item5);
                state2.Transitions.Add(new Transition("running", activity));
                state2.ExitActivity.Activities.Add(item12);
                state2.ExitActivity.Activities.Add(item11);
                state2.ExitActivity.Activities.Add(item13);
                state2.ExitActivity.Activities.Add(item14);
            }
            state3.EnterActivity.Activities.Add(item10);
            state3.Transitions.Add(new Transition(activity2));
            state3.Transitions.Add(new Transition(activity3));
            state3.Transitions.Add(new Transition(activity4));
            state3.Transitions.Add(new Transition(activity5));
            state3.Transitions.Add(new Transition(activity6));
            state3.Transitions.Add(new Transition(activity9));
            state3.Transitions.Add(new Transition(activity10));
            state3.Transitions.Add(new Transition(activity11));
            state3.Transitions.Add(new Transition("raceover", activity7));
            state3.Transitions.Add(new Transition("aborted", activity8));
            state3.ExitActivity.Activities.Add(item15);
            OverrideVehicleControl item20 = new OverrideVehicleControl(base.Entrant.Opponent.Vehicle, OverrideVehicleControl.Control.Stop);
            EnableReplication      item21 = new EnableReplication(base.Entrant.Opponent.Vehicle, false);

            state4.EnterActivity.Activities.Add(item16);
            state4.EnterActivity.Activities.Add(item17);
            state4.EnterActivity.Activities.Add(item18);
            state4.EnterActivity.Activities.Add(item20);
            Abort item22 = new Abort(base.InstancedEvent, base.Entrant);

            state7.EnterActivity.Activities.Add(item22);
            if (base.Entrant.Opponent is LocalHumanOpponent)
            {
                LoadBlackBoards item23 = new LoadBlackBoards(base.Event, BlackBoardFlag.kBlackBoardFlag_Running);
                state3.EnterActivity.Activities.Add(item23);
                WrongWayNotification activity13 = new WrongWayNotification(base.InstancedEvent, base.Entrant);
                NavigateToGPSUpdater activity14 = new NavigateToGPSUpdater(base.InstancedEvent, base.Entrant, Ports.Gameplay);
                state3.Transitions.Add(new Transition(activity13));
                state3.Transitions.Add(new Transition(activity14));
                state4.EnterActivity.Activities.Add(new ChangeBlackBoard(BlackBoardChannel.kBlackBoard_Audio, 2046860387u));
                state4.EnterActivity.Activities.Add(new ChangeBlackBoard(BlackBoardChannel.kBlackBoard_AI, 331198907u));
                state4.EnterActivity.Activities.Add(item6);
                state4.Transitions.Add(new Transition("post"));
                PostEventScreen activity15 = new PostEventScreen(base.InstancedEvent, base.Entrant, Ports.Gameplay);
                AbortEvent      item24     = new AbortEvent(base.InstancedEvent);
                LobbyTick       activity16 = new LobbyTick(0.25f);
                state5.Transitions.Add(new Transition(activity16));
                state5.Transitions.Add(new Transition("done", activity15));
                FinishEntrant          item25 = new FinishEntrant(base.InstancedEvent, base.Entrant, FinishReason.PauseDetected);
                OverrideVehicleControl item26 = new OverrideVehicleControl(base.Entrant.Opponent.Vehicle, OverrideVehicleControl.Control.Release);
                state6.EnterActivity.Activities.Add(item25);
                state6.EnterActivity.Activities.Add(item15);
                state6.Transitions.Add(new Transition("aborted"));
                state7.EnterActivity.Activities.Add(item10);
                state8.EnterActivity.Activities.Add(item24);
                state8.EnterActivity.Activities.Add(item26);
            }
            else
            {
                state4.EnterActivity.Activities.Add(item21);
                state4.Transitions.Add(new Transition("done"));
            }
            state7.Transitions.Add(new Transition("done"));
            CleanupScoringMethod item27 = new CleanupScoringMethod(base.InstancedEvent, base.Entrant);

            state8.EnterActivity.Activities.Add(item27);
            stateGraph.InitialState = "initial";
            stateGraph.DoneState    = "done";
            stateGraph.States.Add(state);
            stateGraph.States.Add(state2);
            stateGraph.States.Add(state3);
            stateGraph.States.Add(state4);
            stateGraph.States.Add(state5);
            stateGraph.States.Add(state7);
            stateGraph.States.Add(state6);
            stateGraph.States.Add(state8);
            return(stateGraph);
        }
Esempio n. 48
0
 public static void DisableTimer()
 {
     Countdown.Stop();
 }
Esempio n. 49
0
 protected void Start()
 {
     cachedGameFlow = GameFlowController.Instance;
     onBlowStatusChanged.Register(OnBlowStatusChange);
     Countdown.Instantiate(3, "GO!", 1.0f, () => { isGamePaused = false; Debug.Log("GO!!!"); });
 }
Esempio n. 50
0
 private void Awake()
 {
     Instance = this;
 }
    protected override void Awake()
    {
        base.Awake();

        changingCountdown = new Countdown(changingDelay.Random);
    }
Esempio n. 52
0
 internal static void NavigateToCountdownPage(this PhoneApplicationPage page, Countdown countdown)
 {
     page.NavigationService.Navigate(new Uri("/CountdownPage.xaml?cd=" + countdown.Title, UriKind.Relative));
 }
Esempio n. 53
0
        private static int RunInstallBat(string installDir, string dataDir)
        {
            Process process = new Process();

            process.StartInfo.WorkingDirectory       = AppDomain.CurrentDomain.BaseDirectory;
            process.StartInfo.FileName               = "install.bat";
            process.StartInfo.Arguments              = "\"" + installDir + "\" \"" + dataDir + "\"";
            process.StartInfo.UseShellExecute        = false;
            process.StartInfo.CreateNoWindow         = true;
            process.StartInfo.RedirectStandardOutput = true;
            process.StartInfo.RedirectStandardError  = true;
            Countdown     countDown = new Countdown(2);
            StringBuilder sb        = new StringBuilder();

            process.OutputDataReceived += (DataReceivedEventHandler)((sender, outLine) =>
            {
                if (outLine.Data != null)
                {
                    try
                    {
                        string data = outLine.Data;
                        sb.AppendLine(data);
                        Logger.Info(data);
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine("Exception in RunInstallBat");
                        Console.WriteLine(ex.ToString());
                    }
                }
                else
                {
                    countDown.Signal();
                }
            });
            process.ErrorDataReceived += (DataReceivedEventHandler)((sender, outLine) =>
            {
                if (outLine.Data != null)
                {
                    try
                    {
                        string data = outLine.Data;
                        sb.AppendLine(data);
                        Logger.Info(data);
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine("A crash occured in RunInstallBat");
                        Console.WriteLine(ex.ToString());
                    }
                }
                else
                {
                    countDown.Signal();
                }
            });
            process.Start();
            process.BeginOutputReadLine();
            process.BeginErrorReadLine();
            int milliseconds = 200000;

            process.WaitForExit(milliseconds);
            Logger.Info("Exit Code for InstallBat " + process.ExitCode.ToString());
            countDown.Wait();
            return(process.ExitCode);
        }
Esempio n. 54
0
        public static IntervalNameCount GetIntervalString(TimeInterval timeInterval, Countdown countdownDateTime)
        {
            string intervalSub = null;
            double count       = 0;

            switch (timeInterval)
            {
            case TimeInterval.Days:
                if (countdownDateTime.NextCountdownDateTime != null)
                {
                    count = countdownDateTime.NextCountdownDateTime.GetDays;
                }
                if (count == 1)
                {
                    intervalSub = AppResources.DayName;
                }
                else
                {
                    intervalSub = AppResources.DayPluralName;
                }
                break;

            case TimeInterval.Minutes:
                if (countdownDateTime.NextCountdownDateTime != null)
                {
                    count = countdownDateTime.NextCountdownDateTime.GetMinutes;
                }
                if (count == 1)
                {
                    intervalSub = AppResources.MinuteName;
                }
                else
                {
                    intervalSub = AppResources.MinutePluralName;
                }
                break;

            case TimeInterval.Hours:
                if (countdownDateTime.NextCountdownDateTime != null)
                {
                    count = countdownDateTime.NextCountdownDateTime.GetHours;
                }
                if (count == 1)
                {
                    intervalSub = AppResources.HourName;
                }
                else
                {
                    intervalSub = AppResources.HourPluralName;
                }
                break;

            case TimeInterval.Seconds:
                if (countdownDateTime.NextCountdownDateTime != null)
                {
                    count = countdownDateTime.NextCountdownDateTime.GetSeconds;
                }
                if (count == 1)
                {
                    intervalSub = AppResources.SecondName;
                }
                else
                {
                    intervalSub = AppResources.SecondPluralName;
                }
                break;

            case TimeInterval.Weeks:
                if (countdownDateTime.NextCountdownDateTime != null)
                {
                    count = countdownDateTime.NextCountdownDateTime.GetWeeks;
                }
                if (count == 1)
                {
                    intervalSub = AppResources.WeekName;
                }
                else
                {
                    intervalSub = AppResources.WeekPluralName;
                }
                break;

            case TimeInterval.Years:
                if (countdownDateTime.NextCountdownDateTime != null)
                {
                    count = countdownDateTime.NextCountdownDateTime.GetYears;
                }
                if (count == 1)
                {
                    intervalSub = AppResources.YearName;
                }
                else
                {
                    intervalSub = AppResources.YearPluralName;
                }
                break;
            }

            var result = new IntervalNameCount(timeInterval, intervalSub, count);

            return(result);
        }
 private void Start()
 {
     resetRotation = transform.localRotation.eulerAngles;
     countdown     = FindObjectOfType <Countdown>();
 }
Esempio n. 56
0
        public override void Assign(Room room)
        {
            Thread.Sleep(1000);

            //分配武将
            AssignGeneralsForPlayers(room, out Dictionary <Player, List <string> > options);
            //武将预览
            foreach (Player p in room.Players)
            {
                List <string> gongxinArgs = new List <string> {
                    string.Empty, JsonUntity.Object2Json(options[p]), string.Empty, string.Empty, "false"
                };
                room.DoNotify(room.GetClient(p), CommandType.S_COMMAND_VIEW_GENERALS, gongxinArgs);
            }

            List <Interactivity> receivers = new List <Interactivity>();
            List <Player>        lords     = new List <Player>();

            foreach (Client client in room.Clients)
            {
                List <string> args = new List <string> {
                    string.Empty, "userdefine:getlandlord", null
                };
                Interactivity inter = room.GetInteractivity(client.UserId);
                if (inter != null)
                {
                    inter.CommandArgs = args;
                    receivers.Add(inter);
                }
            }
            room.DoBroadcastRequest(receivers, CommandType.S_COMMAND_INVOKE_SKILL);
            room.DoBroadcastNotify(CommandType.S_COMMAND_UNKNOWN, new List <string> {
                false.ToString()
            });

            foreach (Player player in room.Players)
            {
                Interactivity client = room.GetInteractivity(player);
                if (client != null && client.IsClientResponseReady && receivers.Contains(client))
                {
                    List <string> invoke = client.ClientReply;
                    if (invoke != null && invoke.Count > 0 && bool.TryParse(invoke[0], out bool success) && success)
                    {
                        lords.Add(player);
                    }
                }
            }

            bool get = true;

            if (lords.Count == 0)
            {
                get   = false;
                lords = new List <Player>(room.Players);
            }
            Player lord = null;

            Shuffle.shuffle(ref lords);
            lord = lords[0];

            if (get)
            {
                LogMessage log = new LogMessage
                {
                    Type = "#get_landlord",
                    From = lord.Name
                };
                room.SendLog(log);
            }
            else
            {
                LogMessage log = new LogMessage
                {
                    Type = "#distribute_landlord",
                    From = lord.Name
                };
                room.SendLog(log);
            }

            foreach (Player p in room.Players)
            {
                if (p == lord)
                {
                    p.Camp = Game3v3Camp.S_CAMP_COOL;
                    p.Role = "lord";
                    room.BroadcastProperty(p, "Camp");
                }
                else
                {
                    p.Role = "rebel";
                }
                room.BroadcastProperty(p, "Role");
            }

            //地主增加2框
            List <string> generals = (List <string>)room.GetTag(Name);

            for (int i = 0; i < 2; i++)
            {
                Shuffle.shuffle(ref generals);
                options[lord].Add(generals[0]);
                generals.RemoveAt(0);
            }

            //选将
            receivers.Clear();
            List <Player> players = new List <Player>();

            foreach (Player player in options.Keys)
            {
                player.SetTag("generals", JsonUntity.Object2Json(options[player]));
                List <string> args = new List <string>
                {
                    player.Name,
                    string.Empty,
                    JsonUntity.Object2Json(options[player]),
                    true.ToString(),
                    true.ToString(),
                    false.ToString()
                };
                Interactivity client = room.GetInteractivity(player);
                if (client != null)
                {
                    client.CommandArgs = args;
                    receivers.Add(client);
                }
                players.Add(player);
            }

            Countdown countdown = new Countdown
            {
                Max  = room.Setting.GetCommandTimeout(CommandType.S_COMMAND_CHOOSE_GENERAL, ProcessInstanceType.S_CLIENT_INSTANCE),
                Type = Countdown.CountdownType.S_COUNTDOWN_USE_SPECIFIED
            };

            room.NotifyMoveFocus(players, countdown);
            room.DoBroadcastRequest(receivers, CommandType.S_COMMAND_CHOOSE_GENERAL);
            room.DoBroadcastNotify(CommandType.S_COMMAND_UNKNOWN, new List <string> {
                false.ToString()
            });

            //给AI和超时的玩家自动选择武将
            foreach (Player player in options.Keys)
            {
                player.RemoveTag("generals");
                if (string.IsNullOrEmpty(player.General1))
                {
                    string        generalName = string.Empty;
                    Interactivity client      = room.GetInteractivity(player);
                    List <string> reply       = client?.ClientReply;
                    bool          success     = true;
                    if (reply == null || reply.Count == 0 || string.IsNullOrEmpty(reply[0]))
                    {
                        success = false;
                    }
                    else
                    {
                        generalName = reply[0];
                    }

                    if (!success || (!options[player].Contains(generalName) && room.GetClient(player).UserRight < 3))
                    {
                        TrustedAI ai = room.GetAI(player);
                        if (ai != null && ai is StupidAI)
                        {
                            generalName = GeneralSelector.GetGeneral(room, options[player], player.GetRoleEnum(), player);
                        }
                        else
                        {
                            generalName = options[player][0];
                        }
                    }

                    player.General1       = generalName;
                    player.ActualGeneral1 = generalName;
                    player.Kingdom        = General.GetKingdom(Engine.GetGeneral(generalName, room.Setting.GameMode).Kingdom[0]);
                    player.General1Showed = true;
                }

                room.BroadcastProperty(player, "General1");
                room.NotifyProperty(room.GetClient(player), player, "ActualGeneral1");
                room.BroadcastProperty(player, "Kingdom");
                room.BroadcastProperty(player, "General1Showed");
                player.PlayerGender = Engine.GetGeneral(player.General1, room.Setting.GameMode).GeneralGender;
                room.BroadcastProperty(player, "PlayerGender");

                player.SetSkillsPreshowed("hd");
                room.NotifyPlayerPreshow(player);
                List <string> names = new List <string> {
                    player.General1
                };
                room.SetTag(player.Name, names);
                room.HandleUsedGeneral(player.General1);
            }

            //神将选国籍
            string        choice  = "wei+qun+shu+wu";
            List <string> prompts = new List <string> {
                "@choose-kingdom"
            };

            receivers.Clear();
            players.Clear();
            foreach (Player player in room.Players)
            {
                if (player.Kingdom != "god")
                {
                    continue;
                }
                List <string> args = new List <string>
                {
                    player.Name,
                    "Kingdom",
                    choice,
                    JsonUntity.Object2Json(prompts)
                };
                Interactivity client = room.GetInteractivity(player);
                if (client != null && !receivers.Contains(client))
                {
                    client.CommandArgs = args;
                    receivers.Add(client);
                }
                players.Add(player);
            }

            countdown = new Countdown
            {
                Max  = room.Setting.GetCommandTimeout(CommandType.S_COMMAND_MULTIPLE_CHOICE, ProcessInstanceType.S_CLIENT_INSTANCE),
                Type = Countdown.CountdownType.S_COUNTDOWN_USE_SPECIFIED
            };
            room.NotifyMoveFocus(players, countdown);
            room.DoBroadcastRequest(receivers, CommandType.S_COMMAND_MULTIPLE_CHOICE);
            room.DoBroadcastNotify(CommandType.S_COMMAND_UNKNOWN, new List <string> {
                false.ToString()
            });

            foreach (Player player in players)
            {
                string        answer        = string.Empty;
                Interactivity interactivity = room.GetInteractivity(player);
                if (interactivity != null)
                {
                    List <string> clientReply = interactivity.ClientReply;
                    if (clientReply != null && clientReply.Count > 0)
                    {
                        answer = clientReply[0];
                    }
                }

                List <string> choices = new List <string>(choice.Split('+'));
                if (string.IsNullOrEmpty(answer) || !choices.Contains(answer))
                {
                    Shuffle.shuffle(ref choices);
                    answer = choices[0];
                }
                player.Kingdom = answer;
                room.BroadcastProperty(player, "Kingdom");
            }
        }
Esempio n. 57
0
 public void Construct()
 {
     Countdown c = new Countdown(10);
 }
Esempio n. 58
0
File: Phone.cs Progetto: dvdfu/ld47
 void Awake()
 {
     countdown = new Countdown(timeLimit);
 }
 void Awake()
 {
     mNetworkManager = (NetworkManager) FindObjectOfType(typeof(NetworkManager));
     mDialogueManager = (DialogueManager) FindObjectOfType(typeof(DialogueManager));
     mCountdown = (Countdown) FindObjectOfType(typeof(Countdown));
     mAvailablePropsList = (dfListbox) FindObjectOfType(typeof(dfListbox));
     mMyProps = (MyProps) FindObjectOfType(typeof(MyProps));
     mGame = (Game) FindObjectOfType(typeof(Game));
 }
    void Awake()
    {
        mNetworkManager = (NetworkManager) FindObjectOfType(typeof(NetworkManager));
        mRecordingPlayer = (RecordingPlayer) FindObjectOfType(typeof(RecordingPlayer));
        mCountdown = (Countdown) FindObjectOfType(typeof(Countdown));
        mScreen = GameObject.FindGameObjectWithTag("Screen");
        mScreenControl = mScreen.GetComponent<dfPanel>();
        mGame = (Game) FindObjectOfType (typeof(Game));
        mDialogueManager = FindObjectOfType<DialogueManager>();

        mDad = GameObject.FindGameObjectWithTag("Dad");
        mMam = GameObject.FindGameObjectWithTag("Mam");
        mSon = GameObject.FindGameObjectWithTag("Son");
        mDaughter = GameObject.FindGameObjectWithTag("Daughter");
        mGrandma = GameObject.FindGameObjectWithTag("Grandma");

        mUIRoot = GameObject.FindGameObjectWithTag("UIRoot");

        mPointGainedIndicatorPrefab = (GameObject)Resources.Load ("Evening/Prefabs/PointGainedIndicator");
    }