Пример #1
0
    public bool cmd(string[] args, FengGameManagerMKII gm)
    {
        if (args.Length == 0)
        {
            ModMain.instance.sendToPlayer(this.help);
            return(true);
        }

        if (args[0].Equals("info", StringComparison.OrdinalIgnoreCase))
        {
            CManager cm = ModMain.instance.getChampionshipManager();
            ModMain.instance.sendToPlayer("Is running? " + cm.isRunning);
            ModMain.instance.sendToPlayer("is in match? " + cm.isInMatch());
            ModMain.instance.sendToPlayer(cm.getInfoString());
            return(true);
        }

        if (args[0].Equals("start", StringComparison.OrdinalIgnoreCase))
        {
            ModMain.instance.getChampionshipManager().start();
            return(true);
        }

        if (args[0].Equals("stop", StringComparison.OrdinalIgnoreCase))
        {
            ModMain.instance.getChampionshipManager().stop();
            return(true);
        }

        ModMain.instance.sendToPlayer("Command not recognized: " + args[0]);
        ModMain.instance.sendToPlayer(this.help);
        return(true);
    }
Пример #2
0
 // Start is called before the first frame update
 private void Awake()
 {
     Parasyte_Stats = FindObjectOfType <PlayerStats>();
     Creature_Image = GetComponentsInChildren <SpriteRenderer>();
     CStats         = GetComponent <CreatureStats>();
     C_man          = GetComponent <CManager>();
 }
Пример #3
0
        Point p2; /* Temporary ending point */

        /* Default constructor */
        public MainWindow()
        {
            InitializeComponent();

            manager = new CManager(PictureCanvas, ListBoxLines); /* Initialize canvas */

            CheckBoxRules.IsChecked = true;                      /* Default checked item */

            /* Initialize combo color */
            ComboColor.ItemsSource            = typeof(Colors).GetProperties();
            ComboColor.SelectedIndex          = 7;
            RadioButtonDefaultColor.IsChecked = true;

            /* Initialize radio button */
            RadioButtonPen.IsChecked               = true;
            RadioButtonUpDown.IsEnabled            = false;
            RadioButtonLeftRight.IsEnabled         = false;
            RadioButtonUpLeft.IsEnabled            = false;
            RadioButtonUpRight.IsEnabled           = false;
            RadioButtonRightTriangle.IsEnabled     = false;
            RadioButtonIsoscelesTriangle.IsEnabled = false;

            /* Initialize ComboBox */
            for (int i = 1; i < 9; i++)
            {
                ComboBoxCOM.Items.Add("COM" + i);
            }
        }
 public void InitialDispaly(Text step, InputField energy, Text startButton, RawImage image, CManager cmanager)
 {
     m_txStep        = step;
     m_txEnergy      = energy;
     m_txStartButton = startButton;
     m_pResImage     = image;
     m_pManager      = cmanager;
 }
Пример #5
0
 public List <SampleCustomer> GetAllCustomers()
 {
     try { return(CManager.GetAllCustomers().Select(temp => new SampleCustomer {
             ID = "https://localhost:44316/api/Customers/" + temp.ID.ToString(), Name = temp.Name, Adress = temp.Adress, OrderIds = temp.orderList.Select(s => "https://localhost:44316/api/Customers/Orders/" + s.ID.ToString()).ToList()
         }).ToList()); }
     catch
     {
         Response.StatusCode = 400;
         return(null);
     }
 }
Пример #6
0
 public ActionResult <SampleCustomer> GetCustomer(int id)
 {
     try
     {
         var temp = CManager.GetCustomer(id);
         return(new SampleCustomer {
             ID = "https://localhost:44316/api/Customers/" + temp.ID.ToString(), Name = temp.Name, Adress = temp.Adress, OrderIds = temp.orderList.Select(s => "https://localhost:44316/api/Customers/Orders/" + s.ID.ToString()).ToList()
         });
     }
     catch { return(NotFound("Customer doesn't exist")); }
 }
    public void StartSimulateUsingCycle(Vector2 vBeta, int iTotalStep, int iSkip, int iStable, int iItera)
    {
        if (m_iTargetStep > 1)
        {
            m_bSimulating = true;
            return;
        }

        if (iTotalStep < 2)
        {
            CManager.ShowMessage("Step must be >= 2 !");
            return;
        }
        if (iSkip < 0)
        {
            CManager.ShowMessage("Skip Step must be >= 0 !");
            return;
        }
        if (iStable < 1)
        {
            CManager.ShowMessage("Stable Step must be >= 1 !");
            return;
        }
        m_eSimType    = ESimulateType.Cycle;
        m_iStepNow    = 0;
        m_iTargetStep = iTotalStep;
        m_iSkipStep   = iSkip;
        m_iStableStep = iStable;
        m_iStableTick = 0;
        m_iIter       = iItera;
        CmpShader.SetInt("iIteration", iItera);
        m_v3Beta = new Vector3(vBeta.x, vBeta.y, (vBeta.y - vBeta.x) / iTotalStep);
        m_lstEnergyList.Clear();
        CmpShader.Dispatch(m_iKernelResetEnergyHistory, 1, 1, 1);

        m_pFloatBuffer = new ComputeBuffer(2, 4);
        m_pFloatBuffer.SetData(new [] { 0.0f, 0.0f });
        CmpShader.SetBuffer(m_iKernelGetEnergyOut, "FloatDataBuffer", m_pFloatBuffer);
        if (-1 != m_iKernelSumUsing)
        {
            CmpShader.Dispatch(m_iKernelSumUsing, m_iSiteNumber[2] / m_iSumDiv, m_iSiteNumber[2] / m_iSumDiv, 1);
        }
        CmpShader.Dispatch(m_iKernelGetEnergyOut, 1, 1, 1);
        m_pFloatBuffer.Release();

        m_bSimulating = true;
        if (null != m_txStartButton)
        {
            m_txStartButton.text = "Pause Simulation";
        }
    }
        public ActionResult <Order> PostCustomerOrders(int id, [FromBody] SampleOrder order)
        {
            try
            {
                var   tempCustomer = CManager.GetCustomer(id);
                Order temp         = new Order(tempCustomer, order.products, order.total);
                OManager.AddOrder(temp);

                return(CreatedAtAction(nameof(GetCustomerOrder), new { Order_id = temp.ID }, temp));
            }
            catch
            {
                return(NotFound("Customer doesn't exist"));
            }
        }
 public ActionResult <List <SampleOrder> > GetAllCustomerOrders(int id)
 {
     try
     {
         CManager.GetCustomer(id);
         return(OManager.GetAllOrdersByCustomerId(id).Select(s => new SampleOrder()
         {
             ID = "https://localhost:44316/api/Customers/Orders/" + s.ID.ToString(), CustomerID = ("https://localhost:44316/api/Customers/" + s.Customer.ID).ToString(), total = s.Total, products = s.products
         }).ToList());
     }
     catch
     {
         return(NotFound("Customer doesn't exist"));
     }
 }
        public ActionResult DeleteCustomerOrders(int id, int Order_ID)
        {
            try
            {
                var tempCustomer = CManager.GetCustomer(id);
                var tempOrder    = tempCustomer.orderList.FirstOrDefault(s => s.ID == Order_ID);
                if (tempOrder == null)
                {
                    return(NotFound("Order doesn't exist"));
                }

                OManager.DeleteOrderById(tempOrder.ID);
                return(NoContent());
            }
            catch { return(NotFound("Customer doesn't exist")); }
        }
Пример #11
0
        public static void SendCCComand(int ccValue = 60, VM_Main vm_sci = null)
        {
            FrequencyManager.ccValue = (byte)ccValue;

            List <Tuple <VM_Main, uint> > restore =
                Globals.Vm_scis
                .Select(w => new Tuple <VM_Main, uint>(w, w.PlotTime))
                .ToList();

            Frequency = 1 / ((6.0 / ccValue));
            foreach (var tuple in restore)
            {
                tuple.Item1.PlotTime = tuple.Item2;
                tuple.Item1.SynchronizeFrequency(vm_sci);
            }
            CManager.WriteToAll("CC", 0, false, false, (ccValue * 3).ToString());
        }
Пример #12
0
    // ReSharper disable once UnusedMember.Local
    void Start()
    {
        Application.runInBackground = true;
        Application.targetFrameRate = -1;

        //32 bit signed int per channel
        //4 bit per site, up to Z16
        //capable for 16 sites
        //4096 x 4096 x 16 - 128^4 sites
        Debug.Log(SystemInfo.SupportsRenderTextureFormat(RenderTextureFormat.RGInt));
        Instance = this;

        m_pCalcs = new [] { G4096_4D, null, G4096_3D, null };
        //RenderTexture r2test = new RenderTexture(16384, 16384, 1, RenderTextureFormat.RGFloat);
        //r2test.enableRandomWrite = true;
        //r2test.Create();
    }
Пример #13
0
 public ActionResult <Customer> PostCustomer([FromBody] sample_object.SampleCustomer cus)
 {
     try
     {
         Customer customer = new Customer(cus.Name, cus.Adress);
         if (CManager.ExistCustomerCheck(customer))
         {
             return(BadRequest("Customer already exists"));
         }
         CManager.AddCustomer(customer);
         return(CreatedAtAction(nameof(GetCustomer), new { id = customer.ID }, customer));
     }
     catch
     {
         throw new Exception("invalid values");
     }
 }
Пример #14
0
 public ActionResult DeleteCustomer(int id)
 {
     try
     {
         var temp = CManager.GetCustomer(id);
         if (temp.orderList.Count == 0)
         {
             CManager.DeleteCustomer(id);
             return(NoContent());
         }
         else
         {
             return(BadRequest("Orders still linked to customer"));
         }
     }
     catch { return(NotFound("Customer doesn't exist")); }
 }
Пример #15
0
        override protected void DisposeNoGcCode()
        {
            if (IsSceneLoading)
            {
                DLog.LogError("异步加载场景未完成时,此时进行卸载GameCore操作,可能引起场景错乱.");
            }
            //公用
            PublicUpdateManager.ClearByKey(AppName);
            NetTool.HttpNet.ClearByKey(AppName);
            NetTool.TCPNet.Instance.ClearAppDelgate(AppName);

            for (int i = mScriptInterfaces.Count - 1; i >= 0; i--)
            {
                ScriptInterface.BehaviourInterfaceBase tscript = mScriptInterfaces[i];
                if (tscript == null)
                {
                    continue;
                }
                if (!tscript.mAppName.Equals(AppName))
                {
                    continue;
                }
                tscript.ClearScriptObject();
            }
            mScriptInterfaces.Clear();

            for (int i = mDontDestroyList.Count - 1; i >= 0; i--)
            {
                DestroyImmediate(mDontDestroyList[i]);
            }
            mDontDestroyList.Clear();

            GManager.DestroyManager();
            AudioManager.DestroyManager();
            LManager.DestroyManager();
            CManager.Dispose();
            SManager.Dispose();

            GManager     = null;
            LManager     = null;
            SManager     = null;
            AudioManager = null;
            CManager     = null;
        }
Пример #16
0
    void Start()
    {
        manager = GameObject.Find("CManager").GetComponent <CManager>();
        weapon  = GetComponent <Weapon>();

        current_health = max_health;

        cameraParent.SetActive(photonView.IsMine);

        if (!photonView.IsMine)
        {
            gameObject.layer = 13;
            // standingCollider.layer = 13;
            crouchingCollider.layer = 13;
            //ChangeLayerRecursively(mesh.transform, 11);
        }
        baseFOV = normalCam.fieldOfView;
        origin  = normalCam.transform.localPosition;


        if (Camera.main)
        {
            Camera.main.enabled = false;
        }

        rig = GetComponent <Rigidbody>();
        weaponParentOrigin     = weaponParent.localPosition;
        weaponParentCurrentPos = weaponParentOrigin;

        if (photonView.IsMine)
        {
            ui_healthbar = GameObject.Find("HUD/Health/Bar").transform;
            ui_armor     = GameObject.Find("HUD/Armor/Bar").transform;
            ui_tutorial  = GameObject.Find("HUD").transform.Find("Tutorial").transform;
            ui_ammo      = GameObject.Find("HUD/Ammo/Text").GetComponent <Text>();
            username     = GameObject.Find("HUD/Username/Text").GetComponent <Text>();
            RefreshArmorBar();
            RefreshHealthBar();
            username.text = Launcher.myProfile.username;
            photonView.RPC("SyncProfile", RpcTarget.All, Launcher.myProfile.username, Launcher.myProfile.level, Launcher.myProfile.xp);
        }
    }
Пример #17
0
        public ActionResult <Customer> PutCustomer(int ID, [FromBody] sample_object.SampleCustomer cus)
        {
            try
            {
                Customer customer = CManager.GetCustomer(ID);
                var      temp     = new Customer(cus.Name, cus.Adress);
                if (CManager.ExistCustomerCheck(temp))
                {
                    return(BadRequest("Customer already exists"));
                }

                customer.SetAdress(cus.Adress);
                customer.SetName(cus.Name);

                CManager.UpdateCustomer(ID, customer);


                return(CreatedAtAction(nameof(GetCustomer), new { id = ID }, CManager.GetCustomer(ID)));
            }
            catch { return(NotFound("Customer doesn't exist")); }
        }
        public ActionResult <SampleOrder> PutCustomerOrders(int id, int Order_ID, [FromBody] SampleOrder order)
        {
            try
            {
                var tempOrder = CManager.GetCustomer(id).orderList.FirstOrDefault(s => s.ID == Order_ID);

                if (tempOrder == null)
                {
                    return(NotFound("Order doesn't exist"));
                }

                tempOrder.SetProduct(order.products);
                tempOrder.SetTotal(order.total);
                OManager.UpdateOrder(tempOrder);
                var temp = OManager.GetOrder(Order_ID);

                return(CreatedAtAction(nameof(GetCustomerOrder), new { Order_id = temp.ID }, temp));
            }
            catch
            {
                return(NotFound("Customer doesn't exist"));
            }
        }
    public void Update()
    {
        if (m_bSimulating)
        {
            switch (m_eSimType)
            {
                #region Fixed
            case ESimulateType.Fixed:
            {
                CmpShader.SetFloat("fRandomSeed", Random.Range(0.0f, 1.0f));
                CmpShader.SetInt("iLatticeStartX", Random.Range(0, m_iSiteNumber[2] - 1));
                CmpShader.SetInt("iLatticeStartY", Random.Range(0, m_iSiteNumber[2] - 1));

                CmpShader.Dispatch(m_iKernelCalcUsing, m_iSiteNumber[2] / m_iCalcDiv, m_iSiteNumber[2] / m_iCalcDiv, 1);
                CmpShader.Dispatch(m_iKernelEnergyUsing, m_iSiteNumber[2] / m_iEnergyDiv, m_iSiteNumber[2] / m_iEnergyDiv, 1);

                if ((m_iStep % m_iEnergyStep) != 0)
                {
                    //accumulate energy and calculate average
                    if (-1 != m_iKernelSumUsing)
                    {
                        CmpShader.Dispatch(m_iKernelSumUsing, m_iSiteNumber[2] / m_iSumDiv, m_iSiteNumber[2] / m_iSumDiv, 1);
                    }
                    CmpShader.Dispatch(m_iKernelGetEnergyOut, 1, 1, 1);
                }

                ++m_iStep;

                if (null != m_txStep)
                {
                    m_txStep.text = m_iStep.ToString();
                }

                if (m_iStep != 0 && (m_iStep % m_iEnergyStep) == 0)
                {
                    CmpShader.Dispatch(m_iKernelDispUsing, m_iSiteNumber[2] / m_iDispDiv, m_iSiteNumber[2] / m_iDispDiv, 1);

                    m_pFloatBuffer = new ComputeBuffer(2, 4);
                    m_pFloatBuffer.SetData(new [] { 0.0f, 0.0f });
                    CmpShader.SetBuffer(m_iKernelGetEnergyOut, "FloatDataBuffer", m_pFloatBuffer);

                    if (-1 != m_iKernelSumUsing)
                    {
                        CmpShader.Dispatch(m_iKernelSumUsing, m_iSiteNumber[2] / m_iSumDiv, m_iSiteNumber[2] / m_iSumDiv, 1);
                    }
                    CmpShader.Dispatch(m_iKernelGetEnergyOut, 1, 1, 1);
                    float[] dataOut = { 0.0f, 0.0f };
                    m_pFloatBuffer.GetData(dataOut);
                    m_lstEnergyStepList.Add(m_iStep);
                    m_lstEnergyList.Add(dataOut[1]);
                    m_lstEnergyList.Add(dataOut[0]);
                    if (null != m_pManager)
                    {
                        m_pManager.LogData(string.Format("step:{0} e:{1}", m_iStep, dataOut[0]));
                    }
                    if (null != m_txEnergy)
                    {
                        m_txEnergy.text = string.Format("Energy: {0}", dataOut[0]);
                    }

                    m_pFloatBuffer.Release();
                    m_pFloatBuffer = null;

                    CmpShader.Dispatch(m_iKernelResetEnergyHistory, 1, 1, 1);
                }

                if (m_iStopStep > 1 && 0 == (m_iStep % m_iStopStep))
                {
                    PauseSimulate();
                    if (null != m_pManager)
                    {
                        m_pManager.OnStopSimulation();
                        string sStp = "\nStep=\n{";
                        string sE   = "\nE=\n{";
                        string sEav = "\nEav=\n{";
                        for (int i = 0; i < m_lstEnergyStepList.Count; ++i)
                        {
                            sStp += m_lstEnergyStepList[i].ToString();
                            sE   += m_lstEnergyList[2 * i].ToString(CultureInfo.InvariantCulture);
                            sEav += m_lstEnergyList[2 * i + 1].ToString(CultureInfo.InvariantCulture);
                            if (i != m_lstEnergyStepList.Count - 1)
                            {
                                sStp += ",";
                                sE   += ",";
                                sEav += ",";
                            }
                            else
                            {
                                sStp += "}\n";
                                sE   += "}\n";
                                sEav += "}\n";
                            }
                        }

                        string sFileName = m_pManager.SaveTextResult(string.Format("Fixed Run at:{0}, with group:{1}\n, size:{6}**4, iteration:{2}, beta:{3}, stop step:{4}, estep:{5}\n"
                                                                                   , DateTime.Now
                                                                                   , m_sGroupName
                                                                                   , m_iIter
                                                                                   , m_fBeta
                                                                                   , m_iStopStep
                                                                                   , m_iEnergyStep
                                                                                   , m_iSiteNumber[1])
                                                                     + sStp + sE + sEav);
                        CManager.ShowMessage("Data save to:" + sFileName);
                        m_pManager.LogData("Stopped. Data save to:" + sFileName);
                    }
                }
            }
            break;
                #endregion

                #region cycle
            case ESimulateType.Cycle:
            {
                if (m_iStepNow == m_iSkipStep && 0 == m_iStableTick)
                {
                    //just enter the cycle
                    //clear energy history and set buffer
                    CmpShader.Dispatch(m_iKernelResetEnergyHistory, 1, 1, 1);
                    m_lstEnergyList.Clear();

                    //only the first time in here, will have m_iStableTick = 0
                    //all others will have m_iStableTick = 1 -> m_iStableStep
                    m_iStableTick = m_iStableStep + 1;
                }

                //we are waiting for it to stable
                if (m_iStableTick > 1)
                {
                    //if (null != m_pManager)
                    //{
                    //    m_pManager.LogData(string.Format("step:{0} stable", m_iStableStep + 2 - m_iStableTick));
                    //}
                    CmpShader.SetFloat("fRandomSeed", Random.Range(0.0f, 1.0f));

                    CmpShader.SetInt("iLatticeStartX", Random.Range(0, m_iSiteNumber[2] - 1));
                    CmpShader.SetInt("iLatticeStartY", Random.Range(0, m_iSiteNumber[2] - 1));
                    CmpShader.Dispatch(m_iKernelCalcUsing, m_iSiteNumber[2] / m_iCalcDiv, m_iSiteNumber[2] / m_iCalcDiv, 1);
                    CmpShader.Dispatch(m_iKernelEnergyUsing, m_iSiteNumber[2] / m_iEnergyDiv, m_iSiteNumber[2] / m_iEnergyDiv, 1);
                    if (-1 != m_iKernelSumUsing)
                    {
                        CmpShader.Dispatch(m_iKernelSumUsing, m_iSiteNumber[2] / m_iSumDiv, m_iSiteNumber[2] / m_iSumDiv, 1);
                    }
                    CmpShader.Dispatch(m_iKernelGetEnergyOut, 1, 1, 1);
                    --m_iStableTick;
                    break;
                }

                //now m_iStableTick = 0 or 1
                //either m_iStepNow < m_iSkipStep
                //or we finish skip
                int iStepNow = m_iStepNow >= m_iSkipStep ? (m_iStepNow - m_iSkipStep) : 0;
                //for example, totalstep = 3490, beta from 0.01 to 3.5
                //stepnow go from 0,1,...,3490,3491,3492,...,(2*3490)
                //when stepnow <= 3490, it is 0.01 + (3.49 / 3490) * stepnow
                //when stepnow > 3490, it is 2*3490 - stepnow.  for example, stepnow = 3491, it is 3490-1, stepnow = 2*3490, it is 0

                //above is give up. we now run for only grow, so iStepNow <= m_iTargetStep
                if (null != m_txStep)
                {
                    m_txStep.text = iStepNow.ToString();
                }
                float fCurrentBetaX = m_v3Beta.x + m_v3Beta.z * iStepNow;

                CmpShader.SetFloat("fBeta", fCurrentBetaX);

                CmpShader.SetFloat("fRandomSeed", Random.Range(0.0f, 1.0f));
                CmpShader.SetInt("iLatticeStartX", Random.Range(0, m_iSiteNumber[2] - 1));
                CmpShader.SetInt("iLatticeStartY", Random.Range(0, m_iSiteNumber[2] - 1));

                //Note for L = 16, m_iSiteNumber[0] = 4, m_iSiteNumber[1] = 16, m_iSiteNumber[2] =  256 for 4D(256x256 texture) and 64 for 3D(64x64 texture)
                CmpShader.Dispatch(m_iKernelCalcUsing, m_iSiteNumber[2] / m_iCalcDiv, m_iSiteNumber[2] / m_iCalcDiv, 1);
                CmpShader.Dispatch(m_iKernelDispUsing, m_iSiteNumber[2] / m_iDispDiv, m_iSiteNumber[2] / m_iDispDiv, 1);

                //when first time in here, we already run for stable
                if (m_iStepNow >= m_iSkipStep && 1 == m_iStableTick)
                {
                    CmpShader.Dispatch(m_iKernelEnergyUsing, m_iSiteNumber[2] / m_iEnergyDiv, m_iSiteNumber[2] / m_iEnergyDiv, 1);
                    m_pFloatBuffer = new ComputeBuffer(2, 4);
                    m_pFloatBuffer.SetData(new [] { 0.0f, 0.0f });
                    CmpShader.SetBuffer(m_iKernelGetEnergyOut, "FloatDataBuffer", m_pFloatBuffer);
                    if (-1 != m_iKernelSumUsing)
                    {
                        CmpShader.Dispatch(m_iKernelSumUsing, m_iSiteNumber[2] / m_iSumDiv, m_iSiteNumber[2] / m_iSumDiv, 1);
                    }
                    CmpShader.Dispatch(m_iKernelGetEnergyOut, 1, 1, 1);
                    float[] dataOut = { 0.0f, 0.0f };
                    m_pFloatBuffer.GetData(dataOut);
                    m_pFloatBuffer.Release();
                    m_pFloatBuffer = null;
                    m_lstEnergyList.Add(dataOut[1]);
                    m_lstEnergyList.Add(dataOut[0]);

                    CmpShader.Dispatch(m_iKernelResetEnergyHistory, 1, 1, 1);

                    if (null != m_pManager)
                    {
                        m_pManager.LogData(string.Format("step:{0} e:{1}", m_iStepNow, dataOut[0]));
                    }
                    m_iStableTick = m_iStableStep + 1;
                }
                else
                {
                    if (null != m_pManager)
                    {
                        m_pManager.LogData(string.Format("step:{0} skipping", m_iStepNow));
                    }
                }

                ++m_iStepNow;
                if (CheckStop())
                {
                    //return;
                }
            }
            break;
                #endregion
            }
        }
    }
Пример #20
0
    public void init(object gm)
    {
        if (File.Exists("log.txt"))
        {
            logOut = File.AppendText("log.txt");
        }
        else
        {
            logOut = File.CreateText("log.txt");
        }
#if DEBUG
        this.debugOut = File.CreateText("debug.log");
#endif

        this.log("====init() was called====");
        try {
            this.fGameManager = (FengGameManagerMKII)gm;
            GameObject go = new GameObject();
            go.name = "ModUI";
            GameObject.DontDestroyOnLoad(go);
            this.modUI = go.AddComponent <ModUI>();

            this.log("----Initializing mod.");
            this.log("Loading the configuration.");
            this.config = ConfigManager.load("config.cfg");
            this.log("Loading settings file.");
            if (File.Exists("settings.json"))
            {
                try {
                    this.settingsObject = JsonObject.fromFile("settings.json");
                    File.Move("settings.json", "settings.json.corrupted" + UnityEngine.Random.Range(0, 10000));
                }catch (JsonException e) {
                    this.log(e);
                    this.settingsObject = new JsonObject();
                }
            }
            else
            {
                this.settingsObject = new JsonObject();
            }

            this.taskManager = new TaskManager();
            gameModInterface = new GameModEventInterface(this);

            this.spawnController = new SpawnController(this.fGameManager, config.get("TitanWaveAmountFunction"), config.get("WaveEndMessage"));

            this.commandBinder = new CommandBinder(this.taskManager);

            this.cManager = new CManager();

            this.nameManager = new NameManager(this.config);
            commandManager   = new CommandManager();

            PhotonNetwork.OnEventCall = this.eventCallback;

            this.averageDamage = float.Parse(config.get("averageDamage"));

            this.log("Initializing extras.");

            this.log("Creating the greeter.");
            greeter = new PlayerGreeter(this);
            this.log("Creating the mod thread.");
            bct  = new MainModThread(this);
            opcm = new OtherPlayerCommandsManager(this.fGameManager);

            thController = new TitanHealthController();

            this.nameChanger = new NameChanger(this);

            this.lagController = new LagController();

            KillCmd.titanName = this.config.get("killTitanName");
            this.setChatLogEnabled(this.getConfig().getBool("chatLogEnabled"));

            this.setUseGas(true);
            this.setUseBlades(true);

            this.log("Registering mod API");
            AoTModAPI.AoTModAPI.setModAPI(this.gameModInterface);

            this.log("Updating values from the settings file.");
            this.log("Starting mod thread.");
            bct.start();
        } catch (System.Exception e) {
            this.log("Error while initializing mod, who knows what will happen.");
            this.log(e);
        }

        this.messagePrefix = this.getConfig().get("messagePrefix");
        this.messageSuffix = this.getConfig().get("messageSuffix");

        this.log("Mod initialized.");

        ModMain.instance = this;
        this.log("Instance: " + ModMain.instance);
        this.commandManager.buildHelpList();
    }
        private void Btn_StopDecelerate_clicked(object sender, RoutedEventArgs e)
        {
            var pckt = Utils.MakePacket(288, 0, false, false);

            CManager.Write(pckt);
        }
Пример #22
0
    public void OnCollisionEnter2D(Collision2D Other)
    {
        if (Other.gameObject.tag == "LatchWall" && Input.GetKey(KeyCode.LeftShift))
        {
            Debug.Log("Roof Latch_Collision = " + RoofLatched);
            if (WallLatched == false)
            {
                WallLatched         = true;
                LatchMove.enabled   = true;
                rigBod.constraints  = RigidbodyConstraints2D.FreezePositionX;
                rigBod.gravityScale = 0;
                PlayCon.enabled     = false;
            }
        }
        if (Other.gameObject.tag == "LatchRoof" && Input.GetKey(KeyCode.LeftShift))
        {
            //Debug.Log("Roof Latch_Collision = " + RoofLatched);
            if (RoofLatched == false)
            {
                RoofLatched         = true;
                LatchMove.enabled   = true;
                rigBod.constraints  = RigidbodyConstraints2D.FreezePositionY;
                rigBod.gravityScale = 0;
                PlayCon.enabled     = false;
                //Debug.Log("Roof Latch = " + RoofLatched);
            }
        }

        if (Other.gameObject.tag == "Creature" && Input.GetKey(KeyCode.LeftShift))
        {
            if (CreatureLatched == false && UnlatchPls == false)
            {
                CreatureLatched = true;
                //CreatureControl = GetComponentInParent<CreatureMovement>();
                transform.parent = Other.transform;
                CreatureControl  = Other.gameObject.GetComponent <CreatureMovement>();
                Victim_Stats     = Other.gameObject.GetComponent <CManager>();
                gameObject.transform.position = Victim_Stats.Creature_Stats.LatchPoint.transform.position;
                //Prey = Other.gameObject;
                if (CreatureControl.enabled == false)
                {
                    CreatureControl.enabled = true;
                }
                if (PlayCon.enabled == true)
                {
                    PlayCon.enabled = false;
                }
                if (LatchMove.enabled == true)
                {
                    LatchMove.enabled = false;
                }
                if (Victim_Stats.Hived == false)
                {
                    //PlayStat.CheckStats.player_Lifepoints += 1;
                    PlayStat.CheckStats.player_Lifepoints += 1;
                    Victim_Stats.Hived = true;
                    Debug.Log(Victim_Stats.Hived);
                }
            }
        }

        if (Other.gameObject.tag == "Spike")
        {
            PlayStat.CheckStats.player_HP += -1;
        }
    }
        private void AddEventHandler(int key, Action <byte[]> action)
        {
            Tuple <int, int> tup = new Tuple <int, int>(key, NodeId);

            CManager.AddEventHandler(tup, action);
        }
Пример #24
0
 private bool Recv(ICommunicationCommand cmd)
 {
     return(CManager.Read(cmd) == 0);
 }
Пример #25
0
 private bool Send(ICommunicationCommand cmd)
 {
     return(CManager.Write(cmd) == 0);
 }
Пример #26
0
    // Update is called once per frame
    void Update()
    {
        if (CreatureLatched == true)
        {
            //Victim_Stats = GetComponentInParent<CreatureStats>();
            gameObject.transform.position = Victim_Stats.Creature_Stats.LatchPoint.transform.position;
            rigBod.isKinematic            = true;
            Player_Collider.enabled       = false;
            //PlayStat.CheckStats.player_HP = PlayStat.CheckStats.player_HP +  Victim_Stats.Creature_Stats.HPBuff;
        }
        //if (CreatureLatched == false)
        //{

        //    PlayStat.CheckStats.player_HP = PlayStat.CheckStats.player_HP;
        //    //PlayStat.StartStats();
        //    //PlayStat.StatsToBuff.player_HP = PlayStat.b_Stats.hitPoints;
        //    //PlayStat.CheckStats.player_HP = PlayStat.b_Stats.hitPoints;
        //   // PlayStat.CheckStats.player_Lifepoints = PlayStat.b_Stats.lifePoints;
        //    //PlayStat.CheckStats.player_JumpForce = PlayStat.b_Stats.jumpForce;
        //    //PlayStat.CheckStats.player_MoveSpeed = PlayStat.b_Stats.moveSpeed;
        //}

        Debug.Log("CreatureLatched = " + CreatureLatched);

        if (WallLatched == true && Input.GetKeyDown(KeyCode.LeftShift))
        {
            //rigBod.constraints = RigidbodyConstraints2D.None;
            //rigBod.constraints = RigidbodyConstraints2D.FreezeRotation;
            WallLatched = false;

            LatchMove.enabled   = false;
            rigBod.constraints  = RigidbodyConstraints2D.None;
            rigBod.constraints  = RigidbodyConstraints2D.FreezeRotation;
            rigBod.gravityScale = 1;
            PlayCon.enabled     = true;
            Debug.Log("Wall Latch = " + WallLatched);
        }

        if (RoofLatched == true && Input.GetKeyDown(KeyCode.LeftShift))
        {
            //rigBod.constraints = RigidbodyConstraints2D.None;
            //rigBod.constraints = RigidbodyConstraints2D.FreezeRotation;
            if (CreatureLatched == true)
            {
                PlayStat.CheckStats.player_HP = PlayStat.CheckStats.player_HP + Victim_Stats.Creature_Stats.HPBuff;
            }
            RoofLatched = false;

            LatchMove.enabled   = false;
            rigBod.constraints  = RigidbodyConstraints2D.None;
            rigBod.constraints  = RigidbodyConstraints2D.FreezeRotation;
            rigBod.gravityScale = 1;
            PlayCon.enabled     = true;
            Debug.Log("Roof Latch = " + RoofLatched);
        }

        if (Input.GetKeyDown(KeyCode.LeftShift))
        {
            if (CreatureLatched == true)
            {
                PlayStat.CheckStats.player_HP = health;
                CreatureLatched = false;
                // Debug.Log("Unlatch pls");
                StartCoroutine(UnlatchTimer());
                transform.parent        = null;
                CreatureLatched         = false;
                CreatureControl.enabled = false;
                Victim_Stats            = null;
                CreatureControl         = null;
                Player_Collider.enabled = true;
                //Physics2D.IgnoreCollision(Player_Collider, Prey.gameObject.GetComponent<Collider2D>());
                // Prey = null;

                rigBod.isKinematic = false;
                if (CreatureControl == true)
                {
                    CreatureControl.enabled = false;
                }
                if (PlayCon.enabled == false)
                {
                    PlayCon.enabled = true;
                }
            }
        }
    }
    private bool CheckStop()
    {
        if (m_iStepNow > m_iTargetStep + m_iSkipStep)
        {
            PauseSimulate();
            if (m_lstEnergyList.Count == 2 * m_iTargetStep + 2)
            {
                string sData = string.Format("Cycle Run at:{0}, group:{1}\n beta={2}:{3}:{4}\n iteration={5}, skip={6}, stable={7}, cycle={8}\n Increasing:\n"
                                             , DateTime.Now
                                             , m_sGroupName
                                             , m_v3Beta.x
                                             , m_v3Beta.z
                                             , m_v3Beta.y
                                             , m_iIter
                                             , m_iSkipStep
                                             , m_iStableStep
                                             , m_iTargetStep
                                             );

                string sBeta = "Beta=\n{";
                string sE    = "E=\n{";
                string sEav  = "Eva=\n{";
                for (int i = 0; i <= m_iTargetStep; ++i)
                {
                    int imx = (i > m_iTargetStep) ? (2 * m_iTargetStep - i) : i;

                    sBeta += (m_v3Beta.x + m_v3Beta.z * imx).ToString();
                    sE    += m_lstEnergyList[2 * i].ToString();
                    sEav  += m_lstEnergyList[2 * i + 1].ToString();
                    if (i != m_iTargetStep)
                    {
                        sBeta += ",";
                        sE    += ",";
                        sEav  += ",";
                    }
                    else
                    {
                        sBeta += "}\n";
                        sE    += "}\n";
                        sEav  += "}\n";
                    }
                }
                sData = sData + sBeta + sE + sEav;

                if (null != m_pManager)
                {
                    string sFileName = m_pManager.SaveTextResult(sData);
                    CManager.ShowMessage("Data save to:" + sFileName);
                    m_pManager.LogData("Stopped. Data save to:" + sFileName);
                }
            }
            else
            {
                if (null != m_pManager)
                {
                    CManager.ShowMessage("Data Count Not Correct ! n = " + m_lstEnergyList.Count);
                    m_pManager.LogData("Stopped");
                }
            }

            if (null != m_pManager)
            {
                m_pManager.OnStopSimulation();
            }
            TerminateSimulateCycle();
            return(true);
        }
        return(false);
    }
Пример #28
0
    public static CGroupTable BuildGroupTable(string sLuaFileName)
    {
        string       sLuaCode = File.ReadAllText(sLuaFileName);
        LuaScriptMgr mgr      = new LuaScriptMgr();

        mgr.DoString(sLuaCode);

        LuaFunction func1 = mgr.GetLuaFunction("GetGroupElementNumber");

        if (null == func1)
        {
            CManager.ShowMessage("GetGroupElementNumber function cannot been found.");
            mgr.Destroy();
            return(null);
        }
        object[] r1 = func1.Call();
        if (2 != r1.Length || !(r1[0] is double && r1[1] is double))
        {
            string sRetInfo = r1.Length + " values:";
            for (int i = 0; i < r1.Length; ++i)
            {
                sRetInfo += (null == r1[i] ? "null" : r1[i].GetType().Name) + ",";
            }
            CManager.ShowMessage("GetGroupElementNumber must return two integers, now return is " + sRetInfo);
            mgr.Destroy();
            return(null);
        }

        int m = Mathf.RoundToInt((float)(double)r1[0]);
        int n = Mathf.RoundToInt((float)(double)r1[1]);

        Debug.Log(string.Format("table m:{0} and n:{1}", m, n));
        if (m + n - 1 >= 4096)
        {
            CManager.ShowMessage(string.Format("mus thave m + n - 1 < 4096, but now m={0}, n={1}", m, n));
            mgr.Destroy();
            return(null);
        }

        LuaFunction func2 = mgr.GetLuaFunction("GetIGTableNumber");

        if (null == func2)
        {
            CManager.ShowMessage("GetIGTableNumber function cannot been found.");
            mgr.Destroy();
            return(null);
        }
        object[] r2 = func2.Call();
        if (1 != r2.Length || !(r2[0] is double))
        {
            string sRetInfo = r2.Length + " values:";
            for (int i = 0; i < r2.Length; ++i)
            {
                sRetInfo += (null == r2[i] ? "null" : r2[i].GetType().Name) + ",";
            }
            CManager.ShowMessage("GetIGTableNumber must return one integer, now return is " + sRetInfo);
            mgr.Destroy();
            return(null);
        }
        int ig = Mathf.RoundToInt((float)(double)r2[0]);

        CGroupTable gt = new CGroupTable
        {
            m_sFileName = "",
            m_eType     = CGroupTable.GroupTableType.Lua,

            m_iM = (short)m,
            m_iN = (short)n,
            m_MI = new short[m + n - 1, m + n - 1],
            m_EI = new float[m],
            m_IG = new short[ig],
        };

        //Fill MT
        LuaFunction func3 = mgr.GetLuaFunction("GetMTTable");

        if (null == func3)
        {
            CManager.ShowMessage("GetMTTable function cannot been found.");
            mgr.Destroy();
            return(null);
        }
        for (int i = 0; i < m + n - 1; ++i)
        {
            for (int j = 0; j < m + n - 1; ++j)
            {
                object[] r3 = func3.Call2(i + 1, j + 1);
                if (1 != r3.Length || !(r3[0] is double))
                {
                    string sRetInfo = r3.Length + " values:";
                    for (int k = 0; k < r3.Length; ++i)
                    {
                        sRetInfo += (null == r3[k] ? "null" : r3[k].GetType().Name) + ",";
                    }
                    CManager.ShowMessage("GetMTTable must return one integer, now return is " + sRetInfo);
                    mgr.Destroy();
                    return(null);
                }

                gt.m_MI[i, j] = (short)(Mathf.RoundToInt((float)(double)r3[0]) - 1);
            }
        }

        //Fill EI
        LuaFunction func4 = mgr.GetLuaFunction("GetETTable");

        if (null == func4)
        {
            CManager.ShowMessage("GetETTable function cannot been found.");
            mgr.Destroy();
            return(null);
        }
        for (int i = 0; i < m; ++i)
        {
            object[] r4 = func4.Call(i + 1);
            if (1 != r4.Length || !(r4[0] is double))
            {
                string sRetInfo = r4.Length + " values:";
                for (int k = 0; k < r4.Length; ++i)
                {
                    sRetInfo += (null == r4[k] ? "null" : r4[k].GetType().Name) + ",";
                }
                CManager.ShowMessage("GetETTable must return one float, now return is " + sRetInfo);
                mgr.Destroy();
                return(null);
            }
            gt.m_EI[i] = (float)(double)r4[0];
        }

        //Fill IG
        LuaFunction func5 = mgr.GetLuaFunction("GetIGTable");

        if (null == func5)
        {
            CManager.ShowMessage("GetIGTable function cannot been found.");
            mgr.Destroy();
            return(null);
        }
        for (int i = 0; i < ig; ++i)
        {
            object[] r5 = func5.Call(i + 1);
            if (1 != r5.Length || !(r5[0] is double))
            {
                string sRetInfo = r5.Length + " values:";
                for (int k = 0; k < r5.Length; ++i)
                {
                    sRetInfo += (null == r5[k] ? "null" : r5[k].GetType().Name) + ",";
                }
                CManager.ShowMessage("GetIGTable must return one integer, now return is " + sRetInfo);
                mgr.Destroy();
                return(null);
            }
            gt.m_IG[i] = (short)(Mathf.RoundToInt((float)(double)r5[0]) - 1);
        }
        mgr.Destroy();
        return(gt);
    }