Ejemplo n.º 1
0
 public void StartChasePlayer()
 {
     player       = GetComponent <Player>();
     muzzle       = player.gameObject;
     muzzle_Type  = Resources.Load("ScriptableObject/MuzzleTypeList") as MuzzleType;
     modeList     = Resources.Load("ModeList/mode") as ModeList;
     muzzleRadius = muzzle_Type.muzzTypeList[mode].GetComponent <SphereCollider>().radius;
     range        = modeList.param[0].Range;
     magazine     = modeList.param[0].Bullet;
 }
Ejemplo n.º 2
0
    void Start()
    {
        muzzleRadius = muzzle_Type[mode].GetComponent <SphereCollider>().radius;

        modeList = Resources.Load("ModeList/mode") as ModeList;

        audioSource = GetComponent <AudioSource>();

        range    = modeList.param[0].Range;
        magazine = modeList.param[0].Bullet;

        Debug.Log("私の戦闘力は" + magazine + "発ですよ!!");
    }
Ejemplo n.º 3
0
 /// <summary>
 /// Takes the input ModeList and replaces this ModeListEditor's ModeList with the input one.
 /// </summary>
 /// <param name="list">Sets the parameters of this ModeListEditor to match the input ModeList.</param>
 public void SetModeList(ModeList list)
 {
     if (this.ListModes == list)
     {
         return; //If already set correctly, return immediately
     }
     ListModes            = list;
     listName.Text        = ListModes.Name;
     listDescription.Text = ListModes.Description;
     CopyOverModesAndButtons(ListModes.Modes);
     populateModesComboBox();
     EnableAndDisableControls();
     fontSizeControl.Value = ConvertToPositiveDecimal(ModeFont.Size);
     fontSizeControl_ValueChanged(new object(), new EventArgs());
 }
Ejemplo n.º 4
0
        /// <summary>
        /// Create a new mode list editor with a list of modes given by the input list.
        /// </summary>
        /// <param name="newID">A unique ID number for the new editor.</param>
        /// <param name="list">Mode list for the new editor to have.</param>
        public ModeListEditor(int newID, ModeList list)
        {
            InitializeComponent();
            listName.Text        = list.Name;
            listDescription.Text = list.Description;
            ListModes            = new ModeList(newID, list);
            Button modeButton;

            foreach (ModeControl modeControl in ListModes.Modes)
            {
                modeButton = CreateButton(modeControl);
                modesFlowPanel.Controls.Add(modeButton);
                CreateDelayEditor(modeControl);
            }

            populateModesComboBox();
            EnableAndDisableControls();
            fontSizeControl.Value = ConvertToPositiveDecimal(ModeFont.Size);
            fontSizeControl_ValueChanged(new object(), new EventArgs());
        }
Ejemplo n.º 5
0
        //string CreateProfile(){}

        void ParseProfile(string profile)
        {
            EventChannel ech;

            channelNumbers = new List <int>();

            _profile = profile;
            XElement root = XElement.Parse(profile);

            IEnumerable <XElement> channels = root.Elements("Mode")
                                              .Where(p => p.Attribute("Value").Value == Mode.ToString()).Elements();

            ChCount = 0;
            foreach (XElement ch in channels)
            {
                channelNumbers.Add(int.Parse(ch.Attribute("ChannelNo").Value));
                ChCount++;
            }

            int modeCount = root.Elements().Count();

            for (int i = 0; i < root.Elements().Count(); i++)
            {
                ModeList.Add(String.Format("Mode_{0}", i + 1));
            }

            if (Id == 0)
            {
                foreach (XElement ch in channels)
                {
                    foreach (XElement evnt in ch.Elements())
                    {
                        ech           = new EventChannel();
                        ech.ChannelNo = int.Parse(ch.Attribute("ChannelNo").Value);
                        ech.EventName = evnt.Attribute("Name").Value;
                        EventChannels.Add(ech);
                    }
                }
            }
        }
        /// <summary>
        /// Remove editors from the page that contain duplicate mode lists.
        /// </summary>
        private void cleanupLists_Click(object sender, EventArgs e)
        {
            //Iterate through ModeListEditors and, if any editor is found to contain a
            //duplicate mode list, then we will remove that editor
            HashSet <ModeListEditor> uniqueModeListEditors     = new HashSet <ModeListEditor>();
            HashSet <int>            duplicateEditorsPositions = new HashSet <int>();
            bool editorIsADuplicate;

            for (int i = 0; i < ModeListEditors.Count; i++)
            {
                editorIsADuplicate = false;

                foreach (ModeListEditor alreadyFoundEditor in uniqueModeListEditors)
                {
                    if (ModeList.Equivalent(alreadyFoundEditor.ListModes, ModeListEditors[i].ListModes))
                    {
                        editorIsADuplicate = true;
                        duplicateEditorsPositions.Add(i);
                        //Since we've already determined that editor is a duplicate, we
                        //needn't continue checking whether this editor is unique
                        break;
                    }
                }

                if (!editorIsADuplicate)
                {
                    uniqueModeListEditors.Add(ModeListEditors[i]);
                }
            }

            //Finally, remove the duplicate editors and layout the page again
            foreach (int ind in duplicateEditorsPositions)
            {
                ModeListEditors.RemoveAt(ind);
            }
            LayoutPage();
        }
Ejemplo n.º 7
0
 /// <summary>
 /// Method for processing extract & format rules
 /// </summary>
 private void ProcessRules(Tuple<Scheme, Level, Option> option, ModeList ruleType, Dictionary<String, String> tokens)
 {
     if (option.Item2.rule != null)
     {
         foreach (Rule r in option.Item2.rule)
         {
             if (r.type == ruleType)
             {
                 // parse the command name & it's parameters
                 Regex rx = new Regex(@"^(.+?)\((.+?)\)$");
                 Match m = rx.Match(r.function);
                 if ((m.Success) &
                     (m.Groups.Count == 3)) //TODO fix regex to have 2 groups & not a match on the whole expression
                 {
                     //TODO Switch to a parser & AST
                     String functionName = m.Groups[1].Value.ToLower().Trim();
                     String[] functionParameters = m.Groups[2].Value.Split(',');
                     //String field1Name = option.Item3.field.Single(f => f.name == functionParameters[0]).name;
                     String field1Value = tokens[functionParameters[0]];
                     switch (functionName)
                     {
                         case "tablelookup":
                             {
                                 // EX: TABLELOOKUP(gs1companyprefixindex,tdt64bitcpi,gs1companyprefixindex,gs1companyprefix)
                                 if (functionParameters[1].Trim().ToLower() == "tdt64bitcpi")
                                 {
                                     tokens.Add(r.newFieldName, _gs1cpi[field1Value]);
                                 }
                                 else
                                 {
                                     throw new TDTTranslationException("TDTFileNotFound " + functionParameters[1] + " auxillary file not found");
                                 }
                                 break;
                             }
                         case "length":
                             {
                                 tokens.Add(r.newFieldName, field1Value.Length.ToString());
                                 break;
                             }
                         case "gs1checksum":
                             {
                                 int checksum;
                                 int weight;
                                 int total = 0;
                                 int len = field1Value.Length;
                                 int d;
                                 for (int i = 0; i < len; i++)
                                 {
                                     if (i % 2 == 0)
                                     {
                                         weight = -3;
                                     }
                                     else
                                     {
                                         weight = -1;
                                     }
                                     d = int.Parse(field1Value.Substring(len - 1 - i, len - i));
                                     total += weight * d;
                                 }
                                 checksum = (10 + total % 10) % 10;
                                 tokens.Add(r.newFieldName, checksum.ToString());
                                 break;
                             }
                         case "substr":
                             {
                                 int offset;
                                 if (!int.TryParse(functionParameters[1], out offset))
                                 {
                                     offset = int.Parse(tokens[functionParameters[1]]);
                                 }
                                 if (functionParameters.Length == 2)
                                 {
                                     tokens.Add(r.newFieldName, field1Value.Substring(offset));
                                 }
                                 else if (functionParameters.Length == 3)
                                 {
                                     int length;
                                     if (!int.TryParse(functionParameters[2], out length))
                                     {
                                         length = int.Parse(tokens[functionParameters[2]]);
                                     }
                                     tokens.Add(r.newFieldName, field1Value.Substring(offset, length));
                                 }
                                 break;
                             }
                         case "concat":
                             {
                                 StringBuilder buffer = new StringBuilder();
                                 for (int p1 = 0; p1 < functionParameters.Length; p1++)
                                 {
                                     Match m2 = new Regex(("\"(.*?)\"|'(.*?)'|[0-9]")).Match(functionParameters[p1]);
                                     if (m2.Success)
                                     {
                                         buffer.Append(functionParameters[p1]);
                                     }
                                     else
                                     {
                                         if (tokens.ContainsKey(functionParameters[p1]))
                                         {
                                             buffer.Append(tokens[functionParameters[p1]]);
                                         }
                                     }
                                 }
                                 tokens.Add(r.newFieldName, buffer.ToString());
                                 break;
                             }
                         case "add":
                             {
                                 int value1 = int.Parse(field1Value);
                                 int value2 = int.Parse(functionParameters[1]);
                                 tokens.Add(r.newFieldName, (value1 + value2).ToString());
                                 break;
                             }
                         case "multiply":
                             {
                                 int value1 = int.Parse(field1Value);
                                 int value2 = int.Parse(functionParameters[1]);
                                 tokens.Add(r.newFieldName, (value1 * value2).ToString());
                                 break;
                             }
                         case "divide":
                             {
                                 int value1 = int.Parse(field1Value);
                                 int value2 = int.Parse(functionParameters[1]);
                                 tokens.Add(r.newFieldName, (value1 / value2).ToString());
                                 break;
                             }
                         case "subtract":
                             {
                                 int value1 = int.Parse(field1Value);
                                 int value2 = int.Parse(functionParameters[1]);
                                 tokens.Add(r.newFieldName, (value1 - value2).ToString());
                                 break;
                             }
                         case "mod":
                             {
                                 int value1 = int.Parse(field1Value);
                                 int value2 = int.Parse(functionParameters[1]);
                                 tokens.Add(r.newFieldName, (value1 % value2).ToString());
                                 break;
                             }
                     }
                 }
             }
         }
     }
 }
Ejemplo n.º 8
0
 //===============================================================================
 // コンストラクタ
 //===============================================================================
 public CameraConfig()
 {
     lookMode = ModeList.NORMAL;
 }
Ejemplo n.º 9
0
        void ExecuteRules(Rule[] rules, ModeList modeList, Dictionary <string, string> parameterDictionary)
        {
            if (rules == null)
            {
                return;
            }

            foreach (Rule r in rules)
            {
                if (r.type.Equals(modeList))
                {
                    // get new field name
                    string newFieldName = r.newFieldName;

                    // get functionname and parameters
                    string[] functionSplit      = r.function.Split(new char[] { '(', ',', ')' }, 128);
                    string   functionName       = functionSplit[0];
                    string[] functionParameters = new string[functionSplit.Length - 2];
                    Array.Copy(functionSplit, 1, functionParameters, 0, functionSplit.Length - 2);
                    int l = functionParameters.Length;

                    string newFieldValue = default(string);

                    switch (functionName)
                    {
                    case "SUBSTR":
                        if ((l == 2) || (l == 3))
                        {
                            string substrInput = parameterDictionary[functionParameters[0]];
                            int    offset      = int.Parse(GetValue(functionParameters[1], parameterDictionary));

                            if (l == 2)
                            {
                                newFieldValue = RuleSUBSTR(substrInput, offset);
                            }
                            else
                            {
                                int length = int.Parse(GetValue(functionParameters[2], parameterDictionary));
                                newFieldValue = RuleSUBSTR(substrInput, offset, length);
                            }
                        }
                        break;

                    case "CONCAT":
                        List <string> concatInput = new List <string>();
                        for (int i = 0; i < l; i++)
                        {
                            string s = GetValue(functionParameters[i], parameterDictionary);
                            concatInput.Add(s);
                        }
                        newFieldValue = RuleCONCAT(concatInput);
                        break;

                    case "GS1CHECKSUM":
                        string value = GetValue(functionParameters[0], parameterDictionary);
                        newFieldValue = RuleGS1CHECKSUM(value);
                        break;

                    // TODO: Implement additional functions.
                    default:
                        throw new TDTTranslationException("TDTNotImplementedException");
                    }

                    // Store the resulting key-value pairs in the associative array after checking that the value
                    // falls entirely within the permitted characterSet (if specified)
                    if (r.characterSet != null)
                    {
                        if (!ValidateCharacterset(newFieldValue, r.characterSet))
                        {
                            throw new TDTTranslationException("TDTFieldOutsideCharacterSet");
                        }
                    }

                    // or within the permitted
                    // numeric range (if decimalMinimum or decimalMaximum are specified)
                    if (r.decimalMinimum != null)
                    {
                        BigInteger integer = BigInteger.Parse(newFieldValue);
                        if (ValidateMinimum(integer, r.decimalMinimum))
                        {
                            throw new TDTTranslationException("TDTFieldBelowMinimum");
                        }
                    }

                    if (r.decimalMaximum != null)
                    {
                        BigInteger integer = BigInteger.Parse(newFieldValue);
                        if (ValidateMaximum(integer, r.decimalMaximum))
                        {
                            throw new TDTTranslationException("TDTFieldAboveMaximum");
                        }
                    }

                    // and performing any necessary padding or stripping of characters.
                    //TODO: Implement padding or stripping of characters.

                    parameterDictionary[newFieldName] = newFieldValue;
                }
            }
        }
Ejemplo n.º 10
0
 public static void Init()
 {
     _mode        = ModeList.Manual;
     auto.State   = false;
     manual.State = true;
 }
Ejemplo n.º 11
0
 /// <summary>
 /// Two mode list editors are considered equivalent if their mode lists are identical.
 /// </summary>
 public static bool Equivalent(ModeListEditor a, ModeListEditor b)
 {
     return(ModeList.Equivalent(a.ListModes, b.ListModes));
 }
Ejemplo n.º 12
0
        /// <summary>
        /// Method for processing extract & format rules
        /// </summary>
        private void ProcessRules(Tuple <Scheme, Level, Option> option, ModeList ruleType, Dictionary <String, String> tokens)
        {
            if (option.Item2.rule != null)
            {
                foreach (Rule r in option.Item2.rule)
                {
                    if (r.type == ruleType)
                    {
                        // parse the command name & it's parameters
                        Regex rx = new Regex(@"^(.+?)\((.+?)\)$");
                        Match m  = rx.Match(r.function);
                        if ((m.Success) &
                            (m.Groups.Count == 3)) //TODO fix regex to have 2 groups & not a match on the whole expression
                        {
                            //TODO Switch to a parser & AST
                            String   functionName       = m.Groups[1].Value.ToLower().Trim();
                            String[] functionParameters = m.Groups[2].Value.Split(',');
                            //String field1Name = option.Item3.field.Single(f => f.name == functionParameters[0]).name;
                            String field1Value = tokens[functionParameters[0]];
                            switch (functionName)
                            {
                            case "tablelookup":
                            {
                                // EX: TABLELOOKUP(gs1companyprefixindex,tdt64bitcpi,gs1companyprefixindex,gs1companyprefix)
                                if (functionParameters[1].Trim().ToLower() == "tdt64bitcpi")
                                {
                                    tokens.Add(r.newFieldName, _gs1cpi[field1Value]);
                                }
                                else
                                {
                                    throw new TDTTranslationException("TDTFileNotFound " + functionParameters[1] + " auxillary file not found");
                                }
                                break;
                            }

                            case "length":
                            {
                                tokens.Add(r.newFieldName, field1Value.Length.ToString());
                                break;
                            }

                            case "gs1checksum":
                            {
                                int checksum;
                                int weight;
                                int total = 0;
                                int len   = field1Value.Length;
                                int d;
                                for (int i = 0; i < len; i++)
                                {
                                    if (i % 2 == 0)
                                    {
                                        weight = -3;
                                    }
                                    else
                                    {
                                        weight = -1;
                                    }
                                    d      = int.Parse(field1Value.Substring(len - 1 - i, len - i));
                                    total += weight * d;
                                }
                                checksum = (10 + total % 10) % 10;
                                tokens.Add(r.newFieldName, checksum.ToString());
                                break;
                            }

                            case "substr":
                            {
                                int offset;
                                if (!int.TryParse(functionParameters[1], out offset))
                                {
                                    offset = int.Parse(tokens[functionParameters[1]]);
                                }
                                if (functionParameters.Length == 2)
                                {
                                    tokens.Add(r.newFieldName, field1Value.Substring(offset));
                                }
                                else if (functionParameters.Length == 3)
                                {
                                    int length;
                                    if (!int.TryParse(functionParameters[2], out length))
                                    {
                                        length = int.Parse(tokens[functionParameters[2]]);
                                    }
                                    tokens.Add(r.newFieldName, field1Value.Substring(offset, length));
                                }
                                break;
                            }

                            case "concat":
                            {
                                StringBuilder buffer = new StringBuilder();
                                for (int p1 = 0; p1 < functionParameters.Length; p1++)
                                {
                                    Match m2 = new Regex(("\"(.*?)\"|'(.*?)'|[0-9]")).Match(functionParameters[p1]);
                                    if (m2.Success)
                                    {
                                        buffer.Append(functionParameters[p1]);
                                    }
                                    else
                                    {
                                        if (tokens.ContainsKey(functionParameters[p1]))
                                        {
                                            buffer.Append(tokens[functionParameters[p1]]);
                                        }
                                    }
                                }
                                tokens.Add(r.newFieldName, buffer.ToString());
                                break;
                            }

                            case "add":
                            {
                                int value1 = int.Parse(field1Value);
                                int value2 = int.Parse(functionParameters[1]);
                                tokens.Add(r.newFieldName, (value1 + value2).ToString());
                                break;
                            }

                            case "multiply":
                            {
                                int value1 = int.Parse(field1Value);
                                int value2 = int.Parse(functionParameters[1]);
                                tokens.Add(r.newFieldName, (value1 * value2).ToString());
                                break;
                            }

                            case "divide":
                            {
                                int value1 = int.Parse(field1Value);
                                int value2 = int.Parse(functionParameters[1]);
                                tokens.Add(r.newFieldName, (value1 / value2).ToString());
                                break;
                            }

                            case "subtract":
                            {
                                int value1 = int.Parse(field1Value);
                                int value2 = int.Parse(functionParameters[1]);
                                tokens.Add(r.newFieldName, (value1 - value2).ToString());
                                break;
                            }

                            case "mod":
                            {
                                int value1 = int.Parse(field1Value);
                                int value2 = int.Parse(functionParameters[1]);
                                tokens.Add(r.newFieldName, (value1 % value2).ToString());
                                break;
                            }
                            }
                        }
                    }
                }
            }
        }
        /// <summary>
        /// Run each mode in the list of modes selected by the user (in the combobox modeListsComboBox).
        /// </summary>
        private void runModeListButton_Click(object sender, EventArgs e)
        {
            //This method takes all of the modes in the selected ModeList and creates a new
            //sequence mode (megaMode) that contains all of the timesteps of the ModeList
            //with a delay timestep inserted between timesteps from different modes.
            //Once the current mode has been changed to megaMode, the "Run Iteration 0"
            //button is clicked to run megaMode, and then megaMode is deleted and the old
            //current mode restored to being the current mode.

            ModeList     selectedList = modeListsComboBox.SelectedItem as ModeList; //The selected list of modes
            SequenceMode megaMode     = new SequenceMode(-1);

            megaMode.ModeName = selectedList.Name;

            //To run megaMode we must set it to be the current mode, so we should first
            //save the current mode so that we can set it back after we have run megaMode
            SequenceMode currentMode = Storage.sequenceData.CurrentMode;

            Storage.sequenceData.CurrentMode = megaMode;
            MainClientForm.instance.sequencePage.setMode(megaMode);

            //New timesteps will be created for megaMode, so we will first store where we
            //started inserting them so that we can remove them after the method completes
            int stepToBeginRemovingAt = Storage.sequenceData.TimeSteps.Count;

            Dictionary <ModeControl, List <TimeStep> > stepsToAdd = new Dictionary <ModeControl, List <TimeStep> >();
            TimeStep newStep;

            //Run through each mode in the list, and for each one add all of its timesteps
            //to stepsTpAdd, as well as any delays between modes
            foreach (ModeControl con in selectedList.Modes)
            {
                stepsToAdd.Add(con, new List <TimeStep>());
                foreach (TimeStep step in Storage.sequenceData.TimeSteps)
                {
                    step.StepEnabled = false;
                    step.StepHidden  = true;
                    if (con.Mode.TimestepEntries.ContainsKey(step) && con.Mode.TimestepEntries[step].StepEnabled)
                    {
                        newStep             = new TimeStep(step);
                        newStep.StepEnabled = true;
                        newStep.StepHidden  = false;
                        megaMode.TimestepEntries.Add(newStep, new SequenceMode.ModeEntry(newStep.StepEnabled, newStep.StepHidden));
                        stepsToAdd[con].Add(newStep);
                    }
                }
                if (con.Delay.ParameterValue > 0)
                {
                    newStep = new TimeStep();
                    newStep.StepDuration = con.Delay;
                    newStep.StepEnabled  = true;
                    newStep.StepHidden   = false;
                    newStep.StepName     = "Delay";
                    megaMode.TimestepEntries.Add(newStep, new SequenceMode.ModeEntry(newStep.StepEnabled, newStep.StepHidden));
                    stepsToAdd[con].Add(newStep);
                }
            }

            //Now we add all of the timesteps in stepsToAdd to megaMode
            foreach (ModeControl con in selectedList.Modes)
            {
                Storage.sequenceData.TimeSteps.AddRange(stepsToAdd[con]);
            }

            //Set megaMode's timesteps to the Sequence page and then finally run it!
            MainClientForm.instance.sequencePage.storeMode_Click(sender, e);
            MainClientForm.instance.sequencePage.modeBox_SelectedIndexChanged(sender, e);
            MainClientForm.instance.RefreshSequenceDataToUI();
            button1_Click(sender, e);

            //Now that it has run remove megaMode and all of its timesteps and set the old
            //current mode back to its rightful place
            Storage.sequenceData.TimeSteps.RemoveRange(stepToBeginRemovingAt, Storage.sequenceData.TimeSteps.Count - stepToBeginRemovingAt);
            MainClientForm.instance.sequencePage.setMode(currentMode);
            Storage.sequenceData.CurrentMode = currentMode;
            MainClientForm.instance.sequencePage.modeBox_SelectedIndexChanged(sender, e);
            MainClientForm.instance.RefreshSequenceDataToUI();
        }