예제 #1
0
    //Random new creature constructor

    public Creature(int partCount)
    {
        int pc = partCount;

        pc -= 1;                                          //This component is taken away from the total number of components allowed
        ComponentPicker compPick = new ComponentPicker(); //Random Gen -> SEED?

        thisObject      = compPick.SelectComponent();     //Random Gen -> SEED?
        DynamicFriction = compPick.GenDynamicFriction();  //Random Gen -> SEED?
        StaticFriction  = compPick.GenStaticFriction();   //Random Gen -> SEED?
        Bounciness      = compPick.GenBounciness();       //Random Gen -> SEED?
        ID = compPick.GetNewID();
        Debug.Log("Title: " + ThisObject + "; ID: " + ID);


        if (pc >= 2) //Random Gen -> SEED?
        {
            int tempMaxBranch = 0;
            if (pc > MAX_BRANCHES)
            {
                tempMaxBranch = MAX_BRANCHES;
            }
            else
            {
                tempMaxBranch = pc;
            }
            int lowerBoundBranches = UnityEngine.Random.Range(0, 2);                              //Random Gen -> SEED?
            int branches           = UnityEngine.Random.Range(lowerBoundBranches, tempMaxBranch); //Random Gen -> SEED?
            childArray = new Creature[branches];
            //pc -= branches;
            for (int i = 0; i < branches; i++)
            {
                int pcPassed = UnityEngine.Random.Range(MIN_BRANCHES, pc); //Random Gen -> SEED?
                pc -= pcPassed;
                Creature c = new Creature(pcPassed);
                childArray[i] = c;
            }
        }
        else if (pc == 1)
        {//Deals with last child object
            childArray = new Creature[1];
            Creature c = new Creature(pc);
            childArray[0] = c;
        }
        else
        {
            childArray = new Creature[0];
        }
    }
예제 #2
0
 private async void CreateComponente_Click(object sender, RoutedEventArgs e)
 {
     if (TabalimApp.CurrentProject?.Tableros.Count > 0)
     {
         var dialog = new ComponentPicker();
         dialog.ShowDialog();
         if (dialog.DialogResult.Value)
         {
             TabalimApp.CurrentTablero.AddComponentTr(dialog.SelectedComponent,
                                                      (Object result) =>
             {
                 circuitosList.Refresh();
             });
         }
     }
     else
     {
         await(this as MetroWindow).ShowMessageAsync("", "Debe existir al menos un tablero.");
     }
 }
예제 #3
0
        /// <summary>
        /// Creates the control(s) necessary for prompting user for a new value
        /// </summary>
        /// <param name="configurationValues">The configuration values.</param>
        /// <param name="id"></param>
        /// <returns>
        /// The control
        /// </returns>
        public override Control EditControl(Dictionary <string, ConfigurationValue> configurationValues, string id)
        {
            try
            {
                ComponentPicker editControl = new ComponentPicker {
                    ID = id
                };

                if (configurationValues != null && configurationValues.ContainsKey("container"))
                {
                    editControl.ContainerType = configurationValues["container"].Value;
                }

                return(editControl);
            }
            catch (SystemException ex)
            {
                return(new LiteralControl(ex.Message));
            }
        }