Exemplo n.º 1
0
        public AddEditLayer(Mode mode)
        {
            InitializeComponent();
            WindowStartupLocation = WindowStartupLocation.CenterScreen;

            CurrentMode = mode;

            ApplyButton.Content = (CurrentMode == Mode.Create) ? "Create layer" : "Edit layer";
            this.Title          = (CurrentMode == Mode.Create) ? "Creating layer" : "Editing layer";
            if (CurrentMode == Mode.Edit)
            {
                OriginalName   = MainWindow.Instance.TileLayerComboBox.SelectedItem.ToString();
                LayerName.Text = OriginalName;
                LayerName.Focus();
                LayerName.SelectAll();
                PositionLabel.IsEnabled = false;
                LayerIndexes.IsEnabled  = false;
            }

            foreach (string layerAlias in Global.Layers)
            {
                LayerIndexes.Items.Add(layerAlias);
            }

            LayerIndexes.SelectedIndex = MainWindow.Instance.TileLayerComboBox.SelectedIndex;

            LayerName.Focus();
        }
Exemplo n.º 2
0
        public Layer(LayerName type)
        {
            List <Neuron> neurons = new List <Neuron>();

            if (type == LayerName.input)
            {
                Type = type;
                for (int i = 0; i < Parameters.InputNeurons; i++)
                {
                    neurons.Add(new Neuron(Parameters.HiddenNeurons, i + 1));
                }
            }
            if (type == LayerName.hidden)
            {
                Type = type;
                for (int i = 0; i < Parameters.HiddenNeurons; i++)
                {
                    neurons.Add(new Neuron(Parameters.OutputNeurons, i + 1));
                }
            }
            if (type == LayerName.output)
            {
                Type = type;
                for (int i = 0; i < Parameters.OutputNeurons; i++)
                {
                    neurons.Add(new Neuron(0, i + 1));
                }
            }
            Neurons = neurons;
        }
Exemplo n.º 3
0
    /// <summary>
    /// 骸骨のFixedUpdate
    /// </summary>
    protected override void EnemyUpdate()
    {
        if (notMoveCounter <= notMoveCount)
        {
            GetComponent <Rigidbody>().position = Vector3.MoveTowards(transform.position, targetCoordinate, moveSpeed);
            if (GetComponent <Rigidbody>().position == targetCoordinate)
            {
                snam            += addAngle;
                cnam            += addAngle;
                targetCoordinate = center + (new Vector3(Mathf.Sin(snam), Mathf.Cos(snam), 0)) * radius;
            }
            Debug.DrawRay(transform.position, (targetCoordinate - transform.position).normalized, Color.red, 0.1f);

            int layer = LayerName.GetMaltMoveHitLayer();
            if (Physics.BoxCast(enemyCenterPos, reverseBoxSize, targetCoordinate - transform.position, new Quaternion(0, 0, 0, 0), reverseRaySize, layer, QueryTriggerInteraction.Ignore))
            {
                addAngle         = -addAngle;
                snam            += addAngle;
                cnam            += addAngle;
                targetCoordinate = center + (new Vector3(Mathf.Sin(snam), Mathf.Cos(snam), 0)) * radius;
                if (notMoveCounter++ >= notMoveCount)
                {
                    GetComponent <Rigidbody>().constraints = RigidbodyConstraints.FreezeAll;
                }
            }
            else
            {
                notMoveCounter = 0;
            }
            SetRotate();
        }
    }
Exemplo n.º 4
0
    public static void SetLayer(GameObject go, LayerName layer, int position)
    {
        SpriteRenderer sr = go.GetComponent <SpriteRenderer>();

        sr.sortingLayerName = layer.ToString();
        sr.sortingOrder     = position;
    }
Exemplo n.º 5
0
        public List <byte> ToBytes()
        {
            List <byte> result = new List <byte>();

            result.AddRange(LayerName.ToBytes());
            result.AddRange(LayerPosition.ToBytes());
            if (LayerBmpFrame == null)
            {
                result.AddRange(BitConverter.GetBytes((Int32)0));
            }
            else
            {
                result.AddRange(BitConverter.GetBytes((Int32)LayerBmpFrame.PixelWidth));
                result.AddRange(BitConverter.GetBytes((Int32)LayerBmpFrame.PixelHeight));

                int    stride = LayerBmpFrame.PixelWidth * (LayerBmpFrame.Format.BitsPerPixel / 8);
                byte[] data   = new byte[LayerBmpFrame.PixelHeight * stride];

                result.AddRange(BitConverter.GetBytes((Int32)data.Length));

                LayerBmpFrame.CopyPixels(data, stride, 0);
                result.AddRange(data);
            }
            return(result);
        }
Exemplo n.º 6
0
        public override void WriteGroupCodes()
        {
            int flags;

            WriteGroupCodeValue(2, LayerName.Trim());
            WriteGroupCodeValue(62, ColorNumber.ToString());
            WriteGroupCodeValue(6, LineTypeName.Trim());

            flags = GetStandardFlags();

            if (IsFrozen)
            {
                flags += 1;
            }
            if (IsFrozenInNewViewports)
            {
                flags += 2;
            }
            if (IsLocked)
            {
                flags += 4;
            }

            WriteGroupCodeValue(70, flags.ToString().Trim());
        }
Exemplo n.º 7
0
 public static void SetLayerContainer(GameObject go, LayerName layer, int position)
 {
     foreach(SpriteRenderer sr in go.GetComponentsInChildren<SpriteRenderer>()) {
         sr.sortingLayerName = layer.ToString();
         sr.sortingOrder = position;
     }
 }
Exemplo n.º 8
0
 static int FindLayerNumber(LayerName name)
 {
     return(Enumerable.Range(0, max)
            .Select(i => LayerMask.LayerToName(i))
            .Where(s => string.Compare(s, name.ToString(), true) == 0)
            .Select(s => LayerMask.NameToLayer(s))
            .FirstOrDefault());
 }
Exemplo n.º 9
0
 public static void SetLayerContainer(GameObject go, LayerName layer, int position)
 {
     foreach (SpriteRenderer sr in go.GetComponentsInChildren <SpriteRenderer>())
     {
         sr.sortingLayerName = layer.ToString();
         sr.sortingOrder     = position;
     }
 }
    //레이어 초기화
    public void ActiveLayer(LayerName layerName)
    {
        for (int i = 0; i < ani.layerCount; i++)
        {
            ani.SetLayerWeight(1, 0);
        }

        ani.SetLayerWeight((int)layerName, 1);
    }
Exemplo n.º 11
0
    public void ActivateLayer(LayerName layerName)
    {
        for (int i = 0; i < animator.layerCount; i++)
        {
            animator.SetLayerWeight(i, 0);
        }

        animator.SetLayerWeight((int)layerName, 1);
    }
Exemplo n.º 12
0
        public static int GetLayer(LayerName name)
        {
            if (!_layerMapping.ContainsKey(name))
            {
                Debug.LogErrorFormat("Layer with name {0} is not defined.", name.ToString());
                throw new Exception("Layer not found");
            }

            return(_layerMapping[name]);
        }
Exemplo n.º 13
0
        private void BtnAddLayer_Click(object sender, RoutedEventArgs e)
        {
            if (string.IsNullOrWhiteSpace(LayerName.Text))
            {
                System.Windows.MessageBox.Show("Layer name missing", "Missing info");
                return;
            }

            TileGrid.AddNewLayer(LayerName.Text);
            LayerName.Clear();
        }
Exemplo n.º 14
0
    /// <summary>
    /// プレーヤーが空中にいるか
    /// </summary>
    /// <returns>trueなら空中</returns>
    bool IsAir()
    {
        int layer = LayerName.GetObjectHitLayer();

        if (Physics.BoxCast(playerCenter, BoxRayScale, Vector3.down, new Quaternion(0, 0, 0, 0), YRaySize, layer, QueryTriggerInteraction.Ignore))
        {
            return(true);
        }

        return(false);
    }
        //---------------------------------------------------------------------
        public Layer(LayerName name, LayerType type)
        {
            this.name     = name;
            this.type     = type;
            this.carbon   = 0.0;
            this.nitrogen = 0.0;

            this.decayValue     = 0.0;
            this.fractionLignin = 0.0;

            this.netMineralization   = 0.0;
            this.grossMineralization = 0.0;
        }
        //---------------------------------------------------------------------
        public Layer(LayerName name, LayerType type)
        {
            this.name = name;
            this.type = type;
            this.carbon = 0.0;
            this.nitrogen = 0.0;

            this.decayValue = 0.0;
            this.fractionLignin = 0.0;

            this.netMineralization = 0.0;
            this.grossMineralization = 0.0;
        }
Exemplo n.º 17
0
    protected override void EnemyUpdate()
    {
        base.EnemyUpdate();

        if (!fallOne)
        {
            if (!fall)
            {
                if (!Physics.BoxCast(enemyCenterPos, boxSize, Vector3.down, new Quaternion(0, 0, 0, 0), raySize, LayerName.GetWallObjectHitLayer()) && GetComponent <Rigidbody>().velocity.y < 0)
                {
                    Collider[] collid = Physics.OverlapBox(enemyCenterPos, boxSize, new Quaternion(0, 0, 0, 0), LayerMask.GetMask(LayerName.BLOCK), QueryTriggerInteraction.Ignore);
                    if (collid.Length == 0)
                    {
                        fall = true;
                    }
                }
            }
            else//落下
            {
                RaycastHit hit;

                Collider[] collid = Physics.OverlapBox(enemyCenterPos, boxSize, new Quaternion(0, 0, 0, 0), LayerMask.GetMask(LayerName.BLOCK), QueryTriggerInteraction.Ignore);

                bool collhit = false;
                if (collid.Length > 0)
                {
                    if ((collid[0].gameObject.layer & LayerName.GetWallObjectHitLayer()) != 0)
                    {
                        FallHitWall();
                    }
                    else
                    {
                        FallHitBlock(collid[0].gameObject);
                    }
                }
                if (!collhit && Physics.BoxCast(enemyCenterPos, boxSize, Vector3.down, out hit, new Quaternion(0, 0, 0, 0), raySize, LayerName.GetObjectHitLayer(), QueryTriggerInteraction.Ignore))
                {
                    if (hit.transform.CompareTag("wall") || hit.transform.CompareTag("endWall"))
                    {
                        FallHitWall();
                    }
                    else
                    {
                        FallHitBlock(hit.transform.gameObject);
                    }
                }
            }
        }
    }
Exemplo n.º 18
0
 private void button1_Click(object sender, EventArgs e)
 {
     if (LayerName == "" || LayerName.All((char c) => c == ' '))
     {
         MessageBox.Show(this, "输入的图层名不能为空。", "图层名错误",
                         MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
     else if (LayerType == null)
     {
         MessageBox.Show(this, "请选择图层类型", "图层类型错误",
                         MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
     else
     {
         DialogResult = DialogResult.OK;
     }
 }
Exemplo n.º 19
0
 protected override void EnemyUpdate()
 {
     transform.position = Vector3.MoveTowards(transform.position, targetPos[moveNam], movePower);
     if (transform.position == targetPos[moveNam])
     {
         reachingPos();
     }
     if (hitReturn)
     {
         int layer = LayerName.GetMaltMoveHitLayer();
         if (Physics.BoxCast(transform.position, hitBoxSize, targetPos[moveNam] - transform.position, new Quaternion(0, 0, 0, 0), hitReturnRaySize, layer, QueryTriggerInteraction.Ignore))
         {
             moveDir *= -1;
             addMoveNam(moveDir);
         }
     }
 }
Exemplo n.º 20
0
    /// <summary>
    /// 蝙蝠のFixedUpdate
    /// </summary>
    protected override void EnemyUpdate()
    {
        int layer = LayerName.GetXMoveHitLayer();

        if (Physics.BoxCast(enemyCenterPos, boxSize, tPos - transform.position, new Quaternion(0, 0, 0, 0), boxRaySize, layer, QueryTriggerInteraction.Ignore))
        {
            moveDir = -moveDir;
            tPos    = new Vector3(transform.position.x, stPos.y, transform.position.z) + new Vector3(moveDir * moveXSize, Mathf.Sin(sinNam) * upNam, 0);
        }

        Debug.DrawRay(enemyCenterPos, (tPos - transform.position) * boxRaySize, Color.blue, 0.2f);

        if (transform.position == tPos)
        {
            sinNam += sinSpeed;
            tPos    = new Vector3(transform.position.x, stPos.y, transform.position.z) + new Vector3(moveDir * moveXSize, Mathf.Sin(sinNam) * upNam, 0);
        }
        transform.position = Vector3.MoveTowards(transform.position, tPos, moveSpeed);
    }
Exemplo n.º 21
0
    /// <summary>
    /// プレイヤーが移動できるかどうかの判定
    /// </summary>
    /// <returns>trueなら移動できる</returns>
    bool IsCanCove()
    {
        RaycastHit hit;

        if (Physics.BoxCast(playerCenter, BoxRayScale, new Vector3(dir, 0, 0), out hit, new Quaternion(0, 0, 0, 0), xRaySize, LayerName.GetObjectHitLayer(), QueryTriggerInteraction.Ignore))
        {
            Vector3 hitpos = hit.point;
            player.transform.position = new Vector3(hitpos.x + (playerXSize * -dir), transform.position.y, transform.position.z);
            return(true);
        }

        //第二
        if (Physics.CheckBox(playerCenter, BoxRayScale, new Quaternion(0, 0, 0, 0), LayerName.GetObjectHitLayer(), QueryTriggerInteraction.Ignore))
        {
            return(true);
        }

        return(true);
    }
Exemplo n.º 22
0
        public LayerItem(Layer item)
        {
            InitializeComponent();
            Item                = item;
            Height              = 100;
            VerticalAlignment   = VerticalAlignment.Top;
            HorizontalAlignment = HorizontalAlignment.Stretch;
            PropertyInfo prop = item.GetType().GetProperty("Name");

            LayerName.Set(prop, item, false, false);
            ToggleVisibilityIcon.Color = Item.Visible ? (Color)Application.Current.Resources["ColorTextLight"] : (Color)Application.Current.Resources["ColorTextDisabled"];
            if (Item.Mask != null)
            {
                MaskRemoveButton.Visibility = Visibility.Visible;
            }
            else
            {
                MaskRemoveButton.Visibility = Visibility.Collapsed;
            }
        }
Exemplo n.º 23
0
    protected override void EnemyUpdate()
    {
        Vector3 moveVDir = new Vector3(0, 0, 0);

        switch (moveDir)
        {
        case MoveDir.Up:
            moveVDir.Set(0, 1, 0);
            break;

        case MoveDir.Right:
            moveVDir.Set(1, 0, 0);

            break;

        case MoveDir.Down:
            moveVDir.Set(0, -1, 0);

            break;

        case MoveDir.Left:
            moveVDir.Set(-1, 0, 0);
            break;
        }

        if (moveCount > 0)
        {
            moveCount--;
            int layer = LayerName.GetMaltMoveHitLayer();
            if (Physics.BoxCast(enemyCenterPos, boxSize, moveVDir, new Quaternion(0, 0, 0, 0), boxRaySize, layer, QueryTriggerInteraction.Ignore))
            {
                turn();
            }
        }
        else
        {
            turn();
        }

        transform.position += (moveVDir * moveSpeed);
    }
        public static void PartitionResidue(
            double inputMass,
            double inputDecayValue,
            double inputCNratio,
            double fracLignin,
            double ratioCNstructural,
            //double CNratiofrass,
            LayerName name,
            LayerType type,
            ActiveSite site)
        {
            double cAddToMetabolic, cAddToStructural, directAbsorb;
            double NAddToMetabolic, NAddToStructural, Npart;
            double fracStructuralLignin, fracMetabolic, fracN, ratioCNtotal, ratioLigninN;
            double totalNitrogen = 0.0;

            double totalC = inputMass * 0.47;

            if (totalC < 0.0000001)
            {
                //PlugIn.ModelCore.UI.WriteLine("C inputs to litter layer below threshold");
                return;
            }

            // ...For each mineral element..
            // ...Compute amount of element in residue.
            Npart = totalC / inputCNratio;

            // ...Direct absorption of mineral element by residue
            //      (mineral will be transferred to donor compartment
            //      and then partitioned into structural and metabolic
            //      using flow routines.)

            // ...If minerl(SRFC,iel) is negative then directAbsorb = zero.
            if (SiteVars.MineralN[site] <= 0.0)
            {
                directAbsorb = 0.0;
            }
            else
            {
                directAbsorb = SiteVars.MineralN[site]
                               * OtherData.FractionSurfNAbsorbed
                               * System.Math.Max(totalC / OtherData.ResidueMaxDirectAbsorb, 1.0);
            }


            // ...If C/N ratio is too low, transfer just enough to make
            //       C/N of residue = damrmn
            if (Npart + directAbsorb <= 0.0)
            {
                ratioCNtotal = 0.0;
            }
            else
            {
                ratioCNtotal = totalC / (Npart + directAbsorb);
            }

            if (ratioCNtotal < OtherData.MinResidueCN)
            {
                directAbsorb = (totalC / OtherData.MinResidueCN) - Npart;
            }

            if (directAbsorb < 0.0)
            {
                directAbsorb = 0.0;
            }

            if (directAbsorb > SiteVars.MineralN[site])
            {
                directAbsorb = SiteVars.MineralN[site];
            }

            SiteVars.MineralN[site] -= directAbsorb;

            totalNitrogen = directAbsorb + Npart;

            // ...Partition carbon into structural and metabolic fraction of
            //      residue (including direct absorption) which is nitrogen
            fracN = totalNitrogen / inputMass; // (totalC * 2.0);

            // ...Lignin/nitrogen ratio of residue
            ratioLigninN = fracLignin / fracN;

            // METABOLIC calculations
            // ...Carbon added to metabolic
            //      Compute the fraction of carbon that goes to metabolic.

            fracMetabolic = OtherData.MetaStructSplitIntercept - OtherData.MetaStructSplitSlope * ratioLigninN;

            // ...Make sure the fraction of residue which is lignin isn't
            //      greater than the fraction which goes to structural.  -rm 12/91
            if (fracLignin > (1.0 - fracMetabolic))
            {
                fracMetabolic = (1.0 - fracLignin);
            }

            // ...Make sure at least 1% goes to metabolic
            if (fracMetabolic < 0.20)
            {
                fracMetabolic = 0.20;
            }

            // ...Compute amounts to flow
            cAddToMetabolic = totalC * fracMetabolic;
            if (cAddToMetabolic < 0.0)
            {
                cAddToMetabolic = 0.0;
            }

            if ((int)type == (int)LayerType.Surface)
            {
                SiteVars.SurfaceMetabolic[site].Carbon += cAddToMetabolic;
            }
            else
            {
                SiteVars.SoilMetabolic[site].Carbon += cAddToMetabolic;
            }

            // STRUCTURAL calculations

            cAddToStructural = totalC - cAddToMetabolic;

            // ...Adjust lignin content of structural.
            // ...fracStructuralLignin is the fraction of incoming structural residue
            //      which is lignin; restricting it to a maximum of .8
            fracStructuralLignin = fracLignin / (cAddToStructural / totalC);

            if ((int)type == (int)LayerType.Surface && cAddToMetabolic <= 0.0)
            {
                //PlugIn.ModelCore.UI.WriteLine("   SURFACE cAddToMetabolic={0}.", cAddToMetabolic);

                // ...Changed allowable maximum fraction from .6 to 1.0  -lh 1/93
                if (fracStructuralLignin > 1.0)
                {
                    fracStructuralLignin = 1.0;
                }
            }

            if ((int)type == (int)LayerType.Surface)
            {
                SiteVars.SurfaceStructural[site].Carbon += cAddToStructural;
            }
            else
            {
                SiteVars.SoilStructural[site].Carbon += cAddToStructural;
            }

            // ...Adjust lignin in Structural Layers
            // adjlig(strucc(lyr), fracStructuralLignin, cAddToStructural, strlig(lyr));

            Layer structuralLayer;

            if ((int)type == (int)LayerType.Surface)
            {
                structuralLayer = SiteVars.SurfaceStructural[site];
            }
            else
            {
                structuralLayer = SiteVars.SoilStructural[site];
            }

            structuralLayer.AdjustLignin(cAddToStructural, fracStructuralLignin);

            // Don't adjust litter decay rate: the base decay rate is
            // always 1.0
            // AdjustDecayRate();

            // ...Partition mineral elements into structural and metabolic
            // ...Flow into structural
            // ...Flow into metabolic
            NAddToStructural = cAddToStructural / ratioCNstructural;  //RATIO CN STRUCTURAL from species data
            NAddToMetabolic  = totalNitrogen - NAddToStructural;

            if ((int)type == (int)LayerType.Surface)
            {
                SiteVars.SurfaceStructural[site].Nitrogen += NAddToStructural;
                SiteVars.SurfaceMetabolic[site].Nitrogen  += NAddToMetabolic;
            }
            else
            {
                SiteVars.SoilStructural[site].Nitrogen += NAddToStructural;
                SiteVars.SoilMetabolic[site].Nitrogen  += NAddToMetabolic;
                //PlugIn.ModelCore.UI.WriteLine("  N added to Structural Soil: {0}.", NAddToStructural);
            }

            return;

            //}
        }
Exemplo n.º 25
0
        public override ArrayList GetGroupCodes()
        {
            ArrayList  list;
            CGroupCode gc;

            list = new ArrayList();

            foreach (CGroupCode tmp in GroupCodeList)
            {
                list.Add(tmp);
            }

            foreach (CEntityVertex vertex in VertexList)
            {
                gc       = new CGroupCode();
                gc.Code  = 0;
                gc.Value = "VERTEX";
                list.Add(gc);

                gc       = new CGroupCode();
                gc.Code  = 5;
                gc.Value = vertex.Handle.Trim();
                list.Add(gc);

                gc       = new CGroupCode();
                gc.Code  = 6;
                gc.Value = vertex.LineType.Trim();
                list.Add(gc);

                gc       = new CGroupCode();
                gc.Code  = 8;
                gc.Value = vertex.LayerName.Trim();
                list.Add(gc);

                foreach (CGroupCode tmp in vertex.GroupCodeList)
                {
                    list.Add(tmp);
                }
            }

            #region SEQEND

            gc       = new CGroupCode();
            gc.Code  = 0;
            gc.Value = "SEQEND";
            list.Add(gc);

            gc       = new CGroupCode();
            gc.Code  = 8;
            gc.Value = LayerName.Trim();
            list.Add(gc);

            gc       = new CGroupCode();
            gc.Code  = 5;
            gc.Value = SeqEndHandle.Trim();
            list.Add(gc);

            #endregion

            return(list);
        }
Exemplo n.º 26
0
 public static int GetLayerNumber(LayerName name)
 {
     return(layers[(int)name]);
 }
Exemplo n.º 27
0
 public static LayerMask GetLayerMask(LayerName name)
 {
     return(layerMasks[(int)name]);
 }
        public static void PartitionResidue(
            double inputMass,
            double inputDecayValue,
            double inputCNratio,
            double fracLignin,
            LayerName name,
            LayerType type,
            ActiveSite site)
        {
            double directAbsorb  = 0.0;
            double ratioCNtotal  = 0.0;
            double totalNitrogen = 0.0;

            // from dry matter to C, 0.47 ratio
            double totalC = inputMass * 0.47;

            if (totalC < 0.0000001)
            {
                return;
            }

            // ...For each mineral element..
            // ...Compute amount of element in residue.
            double Npart = totalC / inputCNratio;

            //PlugIn.ModelCore.UI.WriteLine("                totalCadded={0:0.00}, inputCNratio={1}, name={2}, type={3}.", totalC, inputCNratio, name, type);

            // ...Direct absorption of mineral element by residue
            //      (mineral will be transferred to donor compartment
            //      and then partitioned into structural and metabolic
            //      using flow routines.)

            // ...If minerl(SRFC,iel) is negative then directAbsorb = zero.
            if (SiteVars.MineralN[site] <= 0.0)
            {
                directAbsorb = 0.0;
            }
            else
            {
                directAbsorb = OtherData.FractionSurfNAbsorbed
                               * SiteVars.MineralN[site]
                               * System.Math.Max(totalC / OtherData.ResidueMaxDirectAbsorb, 1.0);
            }


            // ...If C/N ratio is too low, transfer just enough to make
            //       C/N of residue = damrmn
            if (Npart + directAbsorb <= 0.0)
            {
                ratioCNtotal = 0.0;
            }
            else
            {
                ratioCNtotal = totalC / (Npart + directAbsorb);
            }

            if (ratioCNtotal < OtherData.MinResidueCN)
            {
                directAbsorb = (totalC / OtherData.MinResidueCN) - Npart;
            }

            if (directAbsorb < 0.0)
            {
                directAbsorb = 0.0;
            }

            if (directAbsorb > SiteVars.MineralN[site])
            {
                directAbsorb = SiteVars.MineralN[site];
            }

            SiteVars.MineralN[site] -= directAbsorb;

            totalNitrogen = directAbsorb + Npart;

            //PlugIn.ModelCore.UI.WriteLine("                totalNadded={0:0.00}, totalC={1:0.0}, inputCNratio={2}, name={3}, type={4}.", totalNitrogen, totalC, inputCNratio, name, type);


            if ((int)name == (int)LayerName.Wood)
            {
                SiteVars.SurfaceDeadWood[site].Carbon   += totalC;
                SiteVars.SurfaceDeadWood[site].Nitrogen += totalNitrogen;
                SiteVars.SurfaceDeadWood[site].AdjustLignin(totalC, fracLignin);
                SiteVars.SurfaceDeadWood[site].AdjustDecayRate(totalC, inputDecayValue);
            }
            else  // Dead Coarse Roots
            {
                SiteVars.SoilDeadWood[site].Carbon   += totalC;
                SiteVars.SoilDeadWood[site].Nitrogen += totalNitrogen;
                SiteVars.SoilDeadWood[site].AdjustLignin(totalC, fracLignin);
                SiteVars.SoilDeadWood[site].AdjustDecayRate(totalC, inputDecayValue);
            }

            return;
        }
Exemplo n.º 29
0
        private void SetMatrixOrder(PCBI.Automation.IMatrix Matrix, PCBI.Automation.IStep Step)
        {
            if (Step == null || Matrix == null)
            {
                return;
            }

            List <string> MatrixOrder = new List <string>();
            List <string> TopLayers   = new List <string>();
            List <string> BotLayers   = new List <string>();
            List <string> EndLayers   = new List <string>();

            foreach (string LayerName in Step.GetAllLayerNames(true))
            {
                string layerName = LayerName.Replace(".ger", "");
                layerName = LayerName.Replace(".gbr", "");

                if (layerName.EndsWith("silk_screen"))
                {
                    Matrix.SetMatrixLayerParameter(LayerName, MatrixLayerContext.Board, MatrixLayerPolarity.Positive, MatrixLayerType.Silk_screen, 0, 0);
                }
                else if (layerName.EndsWith("solder_paste"))
                {
                    Matrix.SetMatrixLayerParameter(LayerName, MatrixLayerContext.Board, MatrixLayerPolarity.Positive, MatrixLayerType.Solder_paste, 0, 0);
                }
                else if (layerName.EndsWith("solder_mask"))
                {
                    Matrix.SetMatrixLayerParameter(LayerName, MatrixLayerContext.Board, MatrixLayerPolarity.Positive, MatrixLayerType.Solder_mask, 0, 0);
                }
                else if (layerName.EndsWith("power_ground"))
                {
                    Matrix.SetMatrixLayerParameter(LayerName, MatrixLayerContext.Board, MatrixLayerPolarity.Positive, MatrixLayerType.Power_ground, 0, 0);
                }
                else if (layerName.EndsWith("signal"))
                {
                    Matrix.SetMatrixLayerParameter(LayerName, MatrixLayerContext.Board, MatrixLayerPolarity.Positive, MatrixLayerType.Signal, 0, 0);
                    //if (layerName.Contains("top")) //this do not work, because it will be sorted at the end
                    //    MatrixOrder.Insert(0, layerName);
                    //else
                    MatrixOrder.Add(LayerName);      //always in main list
                    continue;
                }
                else if (layerName.EndsWith("drill"))
                {
                    Matrix.SetMatrixLayerParameter(LayerName, MatrixLayerContext.Board, MatrixLayerPolarity.Positive, MatrixLayerType.Drill, 0, 0);
                    EndLayers.Add(LayerName);
                    continue;
                }
                else if (layerName.EndsWith("rout"))
                {
                    Matrix.SetMatrixLayerParameter(LayerName, MatrixLayerContext.Board, MatrixLayerPolarity.Positive, MatrixLayerType.Rout, 0, 0);
                    EndLayers.Add(LayerName);
                    continue;
                }
                else if (layerName.EndsWith("document"))
                {
                    EndLayers.Add(LayerName);
                    continue;
                }

                if (layerName.Contains("top"))// || layerName.Contains("t")) //second check is dangerous depending on your layer naming
                {
                    TopLayers.Add(LayerName);
                }
                else if (layerName.Contains("bot") || layerName.Contains("b"))
                {
                    BotLayers.Add(LayerName);
                }
                else
                {
                    MatrixOrder.Add(LayerName);
                }
            }
            MatrixOrder.Sort();
            TopLayers.Sort();
            BotLayers.Sort();
            EndLayers.Sort();
            MatrixOrder.InsertRange(0, TopLayers);
            MatrixOrder.AddRange(BotLayers);
            MatrixOrder.AddRange(EndLayers);
            Matrix.SetMatrixOrder(MatrixOrder);
        }
Exemplo n.º 30
0
 protected override void EnemyUpdate()
 {
     base.EnemyUpdate();
     if (Physics.BoxCast(enemyCenterPos, boxSize, Vector3.right * moveDir, new Quaternion(0, 0, 0, 0), boxRaySize, LayerName.GetXMoveHitLayer(), QueryTriggerInteraction.Ignore))
     {
         moveDir = -moveDir;
         ChackMoveDir();
     }
     else
     {
         transform.position += new Vector3(moveSpeed * moveDir, 0, 0);
     }
     if (count == createTime)
     {
         count = 0;
         CreateGameobj();
     }
     count++;
 }
        public static void PartitionResidue(
                            double inputMass,
                            double inputDecayValue,
                            double inputCNratio,
                            double fracLignin,
                            double ratioCNstructural,
                            //double CNratiofrass,
                            LayerName name,
                            LayerType type,
                            ActiveSite site)
        {
            double cAddToMetabolic, cAddToStructural, directAbsorb;
            double NAddToMetabolic, NAddToStructural, Npart;
            double fracStructuralLignin, fracMetabolic, fracN, ratioCNtotal, ratioLigninN;
            double totalNitrogen = 0.0;

            double totalC = inputMass * 0.47;

            if (totalC < 0.0000001)
            {
                //PlugIn.ModelCore.UI.WriteLine("C inputs to litter layer below threshold");
                return;
            }

            // ...For each mineral element..
            // ...Compute amount of element in residue.
            Npart = totalC / inputCNratio;

            // ...Direct absorption of mineral element by residue
            //      (mineral will be transferred to donor compartment
            //      and then partitioned into structural and metabolic
            //      using flow routines.)

            // ...If minerl(SRFC,iel) is negative then directAbsorb = zero.
            if (SiteVars.MineralN[site] <= 0.0)
                directAbsorb  = 0.0;
            else
                directAbsorb = SiteVars.MineralN[site]
                                * OtherData.FractionSurfNAbsorbed
                                * System.Math.Max(totalC / OtherData.ResidueMaxDirectAbsorb, 1.0);

            // ...If C/N ratio is too low, transfer just enough to make
            //       C/N of residue = damrmn
            if (Npart + directAbsorb  <= 0.0)
                ratioCNtotal = 0.0;
            else
                ratioCNtotal = totalC / (Npart + directAbsorb);

            if (ratioCNtotal < OtherData.MinResidueCN )
                directAbsorb  = (totalC / OtherData.MinResidueCN) - Npart;

            if (directAbsorb  < 0.0)
                directAbsorb  = 0.0;

            if(directAbsorb > SiteVars.MineralN[site])
                directAbsorb = SiteVars.MineralN[site];

            SiteVars.MineralN[site] -= directAbsorb;

            totalNitrogen = directAbsorb + Npart;

            // ...Partition carbon into structural and metabolic fraction of
            //      residue (including direct absorption) which is nitrogen
            fracN = totalNitrogen / inputMass; // (totalC * 2.0);

            // ...Lignin/nitrogen ratio of residue
            ratioLigninN = fracLignin / fracN;

            // METABOLIC calculations
            // ...Carbon added to metabolic
            //      Compute the fraction of carbon that goes to metabolic.

            fracMetabolic = OtherData.MetaStructSplitIntercept - OtherData.MetaStructSplitSlope * ratioLigninN;

            // ...Make sure the fraction of residue which is lignin isn't
            //      greater than the fraction which goes to structural.  -rm 12/91
            if (fracLignin >  (1.0 - fracMetabolic))
                fracMetabolic = (1.0 - fracLignin);

            // ...Make sure at least 1% goes to metabolic
            if (fracMetabolic < 0.20)
                fracMetabolic = 0.20;

            // ...Compute amounts to flow
            cAddToMetabolic = totalC * fracMetabolic;
            if (cAddToMetabolic < 0.0)
                cAddToMetabolic = 0.0;

            if((int) type == (int) LayerType.Surface)
            {
                SiteVars.SurfaceMetabolic[site].Carbon += cAddToMetabolic;
             }
            else
            {
                SiteVars.SoilMetabolic[site].Carbon += cAddToMetabolic;
            }

            // STRUCTURAL calculations

            cAddToStructural = totalC - cAddToMetabolic;

            // ...Adjust lignin content of structural.
            // ...fracStructuralLignin is the fraction of incoming structural residue
            //      which is lignin; restricting it to a maximum of .8
            fracStructuralLignin = fracLignin / (cAddToStructural / totalC);

            if((int) type == (int) LayerType.Surface && cAddToMetabolic <= 0.0)
                //PlugIn.ModelCore.UI.WriteLine("   SURFACE cAddToMetabolic={0}.", cAddToMetabolic);

            // ...Changed allowable maximum fraction from .6 to 1.0  -lh 1/93
            if (fracStructuralLignin > 1.0)
                fracStructuralLignin = 1.0;

            if((int) type == (int) LayerType.Surface)
            {
                SiteVars.SurfaceStructural[site].Carbon += cAddToStructural;
            }
            else
            {
                SiteVars.SoilStructural[site].Carbon += cAddToStructural;
            }

            // ...Adjust lignin in Structural Layers
            // adjlig(strucc(lyr), fracStructuralLignin, cAddToStructural, strlig(lyr));

            Layer structuralLayer;

            if((int) type == (int) LayerType.Surface)
                structuralLayer = SiteVars.SurfaceStructural[site];
            else
                structuralLayer = SiteVars.SoilStructural[site];

            structuralLayer.AdjustLignin(cAddToStructural, fracStructuralLignin);

            // Don't adjust litter decay rate: the base decay rate is
            // always 1.0
            // AdjustDecayRate();

            // ...Partition mineral elements into structural and metabolic
            // ...Flow into structural
            // ...Flow into metabolic
            NAddToStructural = cAddToStructural / ratioCNstructural;  //RATIO CN STRUCTURAL from species data
            NAddToMetabolic = totalNitrogen - NAddToStructural;

            if((int) type == (int) LayerType.Surface)
            {
                SiteVars.SurfaceStructural[site].Nitrogen += NAddToStructural;
                SiteVars.SurfaceMetabolic[site].Nitrogen += NAddToMetabolic;
            }
            else
            {
                SiteVars.SoilStructural[site].Nitrogen += NAddToStructural;
                SiteVars.SoilMetabolic[site].Nitrogen += NAddToMetabolic;
                //PlugIn.ModelCore.UI.WriteLine("  N added to Structural Soil: {0}.", NAddToStructural);
            }

            return;

            //}
        }
Exemplo n.º 32
0
        /// <summary>
        /// 数据源图层名
        /// </summary>
        public void OnExecute()
        {
            switch (ActionArgument)
            {
            case ActionTypes.Adjust:
            {
                new ArcEngineLicense();
                SpatialAdjust.Adjust();
                break;
            }

            case ActionTypes.ImportData:
            {
                if (new string[] { Datasource, LayerName, OutDatasource, OutLayerName, ControlPoints }.Any(s => s == null))
                {
                    Console.WriteLine("参数没有写全");
                    break;
                    //throw new Exception("参数没有写全");
                }
                new ArcEngineLicense();
                SpatialAdjust sa = null;
                try
                {
                    sa = new SpatialAdjust(controlPointsFile: ControlPoints, controlPointsInputType: ControlPointsInputType, spatialAdjustMethodType: SpatialAdjustMethodType);
                }
                catch (Exception ex)
                {
                    sa = null;
                }
                var inFc = DataActions.GetFeatureClass(Datasource, DataSourceType, LayerName);
                ESRI.ArcGIS.Geodatabase.IFeatureClass outFc;
                try
                {
                    outFc = DataActions.GetFeatureClass(OutDatasource, OutDatasourceType, OutLayerName);
                }
                catch (Exception)
                {
                    outFc = DataActions.CreateFeatureClass(DataActions.GetWorkspace(OutDatasource, OutDatasourceType), "", OutLayerName, inFc);
                }
                //Console.WriteLine($"将使用{ SpatialAdjust.transformMethodMap[sa.SpatialAdjustMethodType].Name} 偏移");
                DataActions.CoverFeatureClassWithFeatureClass(inFc, outFc, sa);
                break;
            }

            case ActionTypes.LogLayer:
            {
                new ArcEngineLicense();
                LogActions.LogFeatureClass(Datasource, DataSourceType, LayerName);
            }
            break;

            case ActionTypes.BatchImport:
            {
                new ArcEngineLicense();
                var           layerNames          = LayerName.Split(',');
                List <string> finalNameStringList = new List <string>();
                var           workspace           = DataActions.GetWorkspace(Datasource, DataSourceType);
                var           featureWorkspace    = (IFeatureWorkspace)workspace;
                layerNames.ToList().ForEach((name) =>
                    {
                        try
                        {
                            featureWorkspace.OpenFeatureClass(name);
                            finalNameStringList.Add(name);
                        }
                        catch (Exception)
                        {
                            try
                            {
                                var dataset = featureWorkspace.OpenFeatureDataset(name);
                                var subs    = dataset.FeatureDatasetsInFeatureDataset();
                                subs.ToList().ForEach(sub => finalNameStringList.Add(sub.Name));
                            }
                            catch (Exception)
                            {
                            }
                        }
                    });
                finalNameStringList.ForEach((finalName) =>
                    {
                        new CommandLineController()
                        {
                            ActionArgument          = ActionTypes.ImportData,
                            Datasource              = Datasource,
                            DataSourceType          = DataSourceType,
                            LayerName               = finalName,
                            OutDatasource           = OutDatasource,
                            OutDatasourceType       = OutDatasourceType,
                            OutLayerName            = $"{finalName.Split('.').Last()}_adjusted",
                            ControlPoints           = ControlPoints,
                            ControlPointsInputType  = ControlPointsInputType,
                            SpatialAdjustMethodType = SpatialAdjustMethodType
                        }.OnExecute();
                    });
            }
            break;

            case ActionTypes.GenerateBatch:
            {
                new ArcEngineLicense();
                var batchFileName = String.Empty;
                //var dtn = DateTime.Now.ToFullTimeSecondString();
                if (String.IsNullOrEmpty(BatchFileName))
                {
                    var dtn = DateTime.Now;
                    var s   = dtn.ToBinary();
                    batchFileName = $"bat{s}.bat";
                }
                else
                {
                    batchFileName = BatchFileName;
                }
                var           layerNames          = LayerName.Split(',');
                List <string> finalNameStringList = new List <string>();
                var           workspace           = DataActions.GetWorkspace(Datasource, DataSourceType);
                var           featureWorkspace    = (IFeatureWorkspace)workspace;
                layerNames.ToList().ForEach((name) =>
                    {
                        try
                        {
                            featureWorkspace.OpenFeatureClass(name);
                            finalNameStringList.Add(name);
                        }
                        catch (Exception)
                        {
                            try
                            {
                                var dataset = featureWorkspace.OpenFeatureDataset(name);
                                var subs    = dataset.FeatureDatasetsInFeatureDataset();
                                subs.ToList().ForEach(sub => finalNameStringList.Add(sub.Name));
                            }
                            catch (Exception)
                            {
                            }
                        }
                    });


                using (StreamWriter sw = new StreamWriter(batchFileName, true, Encoding.Default))
                //using (StreamWriter sw = File.AppendText(batchFileName))
                {
                    var text = String.Empty;

                    finalNameStringList.ToList().ForEach((layerName) =>
                        {
                            //System.Reflection.Assembly.GetExecutingAssembly().FullName;
                            //sw.WriteLine( $"AoCli.exe "  )
                            sw.WriteLine($@"AoCli.exe BatchImport -ln {layerName} -ds {Datasource} -dst {DataSourceType} -ods {OutDatasource} -odst {OutDatasourceType} -oln {OutLayerName} -cp {ControlPoints} -samt {SpatialAdjustMethodType}" + " \n");
                            //text += $@"AoCli.exe BatchImport -ln {layerName} -ds {Datasource} -dst {DataSourceType} -ods {OutDatasource} -oln {OutLayerName} -cp {ControlPoints} -samt {SpatialAdjustMethodType}";
                            //text += "\n";
                        });
                    sw.Write(text);


                    Console.WriteLine("Batch file generated");
                }
            }
            break;

            case ActionTypes.GPTest:
            {
                new Test.MyTestClass().ShapeInWhereTest3();
            }
            break;

            default:
                break;
            }
        }
Exemplo n.º 33
0
 /// <summary>
 /// 天使のFixedUpdate
 /// </summary>
 protected override void EnemyUpdate()
 {
     if (down)//降下
     {
         if (Physics.BoxCast(enemyCenterPos, rayBoxSize, Vector3.down, new Quaternion(0, 0, 0, 0), downRaySize, LayerName.GetObjectHitLayer(), QueryTriggerInteraction.Ignore))
         {
             down          = false;
             downSizeCount = 0;
         }
         else
         {
             transform.position += Vector3.down * moveSpeed;
             downSizeCount      += moveSpeed;
             if (downSizeCount >= downSize)
             {
                 down          = false;
                 downSizeCount = 0;
             }
         }
     }
     else//左右移動
     {
         RaycastHit hit;
         if (Physics.BoxCast(enemyCenterPos, rayBoxSize, new Vector3(moveDir, 0, 0), out hit, new Quaternion(0, 0, 0, 0), raySize, LayerName.GetXMoveHitLayer(), QueryTriggerInteraction.Ignore))
         {
             if (hit.transform.CompareTag("enemy"))
             {
                 //反転
                 moveDir = -moveDir;
             }
             else if (hit.transform.CompareTag("wall") || hit.transform.CompareTag("blockObj"))
             {
                 //降下
                 down    = true;
                 moveDir = -moveDir;
             }
         }
         else
         {
             transform.position += new Vector3(moveSpeed * moveDir, 0, 0);
         }
     }
 }
        public static void PartitionResidue(
                            double inputMass,
                            double inputDecayValue,
                            double inputCNratio,
                            double fracLignin,
                            LayerName name,
                            LayerType type,
                            ActiveSite site)
        {
            double directAbsorb = 0.0;
            double ratioCNtotal = 0.0;
            double totalNitrogen = 0.0;

            // from dry matter to C, 0.5 ratio
            double totalC = inputMass * 0.47;

            if (totalC < 0.0000001)
                return;

            // ...For each mineral element..
            // ...Compute amount of element in residue.
            double Npart = totalC / inputCNratio;

            //UI.WriteLine("tC={0}, inputCNratio={1}, name={2}, type={3}.", totalC, inputCNratio, name, type);

            // ...Direct absorption of mineral element by residue
            //      (mineral will be transferred to donor compartment
            //      and then partitioned into structural and metabolic
            //      using flow routines.)

            // ...If minerl(SRFC,iel) is negative then directAbsorb = zero.
            if (SiteVars.MineralN[site] <=  0.0)
                directAbsorb  = 0.0;
            else
                directAbsorb = OtherData.FractionSurfNAbsorbed
                                * SiteVars.MineralN[site]
                                * System.Math.Max(totalC / OtherData.ResidueMaxDirectAbsorb, 1.0);

            // ...If C/N ratio is too low, transfer just enough to make
            //       C/N of residue = damrmn
            if (Npart + directAbsorb  <= 0.0)
                ratioCNtotal = 0.0;
            else
                ratioCNtotal = totalC / (Npart + directAbsorb);

            if (ratioCNtotal < OtherData.MinResidueCN )
                directAbsorb  = (totalC / OtherData.MinResidueCN) - Npart;

            if (directAbsorb  < 0.0)
                directAbsorb  = 0.0;

            if(directAbsorb > SiteVars.MineralN[site])
                directAbsorb = SiteVars.MineralN[site];

            SiteVars.MineralN[site] -= directAbsorb;

            totalNitrogen = directAbsorb + Npart;

            Layer layer;

            if((int) name == (int) LayerName.Wood)
                layer = SiteVars.SurfaceDeadWood[site];
            else
                layer = SiteVars.SoilDeadWood[site];

            layer.Carbon += totalC;
            layer.Nitrogen += totalNitrogen;

            // ...Adjust lignin and decay rates in Structural Layers
            layer.AdjustLignin(totalC, fracLignin);
            layer.AdjustDecayRate(totalC,  inputDecayValue);

            return;

            //}
        }
Exemplo n.º 35
0
 public static void SetLayer(GameObject go, LayerName layer, int position)
 {
     SpriteRenderer sr = go.GetComponent<SpriteRenderer>();
     sr.sortingLayerName = layer.ToString();
     sr.sortingOrder = position;
 }