Esempio n. 1
0
    protected RangeObject GetMinDistanceObj(string tag)
    {
        // Check all objects in the list
        RangeObject objReturn = null;

        if (ranges != null && ranges.Count != 0)
        {
            float minDistance = ranges[0].RangeDistance;
            int   minIndex    = 0;
            // Get the nearest object
            for (int i = 0; i < ranges.Count; ++i)
            {
                if (ranges[i].RangeGameObject.tag == tag || tag == "")
                {
                    if (ranges[i].RangeDistance < minDistance)
                    {
                        minDistance = ranges[i].RangeDistance;
                        minIndex    = i;
                    }
                }
            }
            objReturn = ranges[minIndex];
        }
        // Return the distance
        return(objReturn);
    }
Esempio n. 2
0
        public CreateRangeObject()
        {
            InitializeComponent();

            foreach (var type in RangeObject.ValidTypes)
            {
                var typeName = RangeObject.GetTypeNameFromId(type);

                types.Add(typeName, type);

                cmbType.Items.Add(typeName);
            }

            if (RangeObject.ValidTypes.Length > 0)
            {
                cmbType.SelectedIndex = 0;
            }

            Text           = Strings.CreateRangeObject;
            lblId.Text     = Strings.ID;
            lblMapId.Text  = Strings.MapID;
            lblType.Text   = Strings.Type;
            lblX1.Text     = Strings.X1Pos;
            lblY1.Text     = Strings.Y1Pos;
            lblX2.Text     = Strings.X2Pos;
            lblY2.Text     = Strings.Y2Pos;
            btnCreate.Text = Strings.Create;

            this.SetFonts();
        }
Esempio n. 3
0
    private static void DrawPointGizmos(RangeObject i_object, GizmoType i_gizmoType)
    {
        if (i_object.Length <= 0.0f)
        {
            return;
        }

        Gizmos.color = MESH_COLOR;

        Transform  transform = i_object.transform;
        Vector3    pos       = transform.position + Vector3.up * 0.01f; // 0.01fは地面と高さだと見づらいので調整用。
        Quaternion rot       = transform.rotation;
        Vector3    scale     = Vector3.one * i_object.Length;


        if (i_object.HeightAngle > 0.0f)
        {
            Mesh fanMesh = CreateFanMesh(i_object.HeightAngle, TRIANGLE_COUNT);

            Gizmos.DrawMesh(fanMesh, pos, rot * Quaternion.AngleAxis(90.0f, Vector3.forward), scale);
            Gizmos.DrawMesh(fanMesh, pos, rot * Quaternion.AngleAxis(270.0f, Vector3.forward), scale);
        }

        if (i_object.WidthAngle > 0.0f)
        {
            Mesh fanMesh = CreateFanMesh(i_object.WidthAngle, TRIANGLE_COUNT);

            Gizmos.DrawMesh(fanMesh, pos, rot, scale);
            Gizmos.DrawMesh(fanMesh, pos, rot * Quaternion.AngleAxis(180.0f, Vector3.forward), scale);
        }
    }
Esempio n. 4
0
        private void AddObject()
        {
            var id     = int.Parse(txtId.Text);
            var typeId = GetTypeIdFromName(cmbType.Text);

            var point = new RangeObject()
            {
                Id          = id,
                Type        = typeId,
                Destination = int.Parse(txtMapId.Text),
                X1          = int.Parse(txtX1.Text),
                Y1          = int.Parse(txtY1.Text),
                X2          = int.Parse(txtX2.Text),
                Y2          = int.Parse(txtY2.Text)
            };

            Map.RangeObjects.Add(point);
            RangeListForm.RepopulateData();
        }
 private void SetGrab()
 {
     // If there any itens in the target list
     if (ranges.Count > 0)
     {
         RangeObject picking = GetMinAngleObj("Pickup");
         // Check if are some pickup itens in list
         _pickedItem = picking.RangeGameObject;
         if (_pickedItem != null && _pickedItem.tag == "Pickup")
         {
             // Set picking animation
             _picking = true;
             // Change picked item layer & configs to drag
             _pickedItem.gameObject.layer        = 11;
             _pickedItem.rigidbody2D.isKinematic = true;
             _pickedItem.GetComponent <SpriteRenderer>().sortingLayerName = "Pickup";
             // Set player as parent of the item
             _pickedItem.transform.parent = obj.transform;
             // Move item to the players head
             _pickedItem.transform.localPosition = new Vector3(0, 0.6f, 0);
         }
     }
 }
Esempio n. 6
0
        public RangeObjectForm()
        {
            InitializeComponent();

            // Initialize localization
            idHeader.Text    = Strings.ID;
            typeHeader.Text  = Strings.Type;
            mapIdHeader.Text = Strings.MapID;
            x1PosHeader.Text = Strings.X1Pos;
            y1PosHeader.Text = Strings.Y1Pos;
            x2PosHeader.Text = Strings.X2Pos;
            y2PosHeader.Text = Strings.Y2Pos;

            btnCreate.Text = Strings.Create;
            btnDelete.Text = Strings.Delete;
            btnEdit.Text   = Strings.Edit;

            foreach (var type in RangeObject.ValidTypes)
            {
                var typeName = RangeObject.GetTypeNameFromId(type);

                types.Add(typeName, type);
            }
        }
Esempio n. 7
0
 private void Start()
 {
     parameter = GetComponent <RangeObject>();
 }
Esempio n. 8
0
        private void GenerateGraphicalData()
        {
            int graphdataCount = mRunningSumArray.Length;
            if (mMemoryGraphPB.Width > 0 && graphdataCount > 0)
            {
                mTargetWidth = mMemoryGraphPB.Width * mGraphScale;
                mMemoryGraphRangeData = new RangeObject[mTargetWidth];
                mWidthUnit = (float)mTargetWidth / (float)graphdataCount;
                int prevIndex = 0;
              //  int rangeMin = (int)mRunningSumArray[0];
                int rangeMax = mRunningSumArray[0];

                int[] rangeCategoryMax = null;
                if(mCategoryEnabled)
                {
                    //  int[] rangeCategoryMin = new int[mNumberOfCategories];
                    rangeCategoryMax = new int[mNumberOfCategories];
                    for (int k = 0; k < mNumberOfCategories; k++)
                    {
                        // rangeCategoryMin[k] = (int)mCategoryRunningSumArrays[k][0];
                        rangeCategoryMax[k] = (int)mCategoryRunningSumArrays[k][0];
                    }
                }

                int unfilteredMax = mUnflilteredRunningSumArrays[0];
                int startIndex = 0;
                int gdataIndex = 0;
                float prop = (float)mTargetWidth / (float)(graphdataCount - 1);
                for (int dataIndex = 1; dataIndex < graphdataCount; dataIndex++)
                {
                    int targetIndex = (int)((float)dataIndex * prop);
                    if (targetIndex != prevIndex)
                    {
                        System.Diagnostics.Debug.Assert(targetIndex - prevIndex == 1, "What is up!");

                        RangeObject range = new RangeObject();
                        range.mMax = rangeMax;
                        range.mLogIndex = new Range(startIndex, dataIndex - 1);
                        if (mCategoryEnabled)
                        {
                            mMemoryGraphRangeData[gdataIndex].mCategoryMemory = new ArrayList(mNumberOfCategories);

                            for (int k = 0; k < mNumberOfCategories; k++)
                            {
                                range.mCategoryMemory.Add(rangeCategoryMax[k]);
                                //  rangeCategoryMin[k] = (int)mCategoryRunningSumArrays[k][dataIndex];
                                rangeCategoryMax[k] = (int)mCategoryRunningSumArrays[k][dataIndex];
                            }
                        }

                        range.mUnfilteredMax = unfilteredMax;
                        mMemoryGraphRangeData[gdataIndex++] = range;

                        prevIndex = targetIndex;

                        startIndex = dataIndex;
                        //rangeMin = (int)mRunningSumArray[dataIndex];
                        rangeMax = mRunningSumArray[dataIndex];
                        unfilteredMax = mUnflilteredRunningSumArrays[dataIndex];
                    }
                    else
                    {
                        rangeMax = Math.Max(rangeMax, mRunningSumArray[dataIndex]);
                        for (int j = 0; j < mNumberOfCategories; j++)
                        {
                          //  rangeCategoryMin[j] = Math.Min(rangeCategoryMin[j], (int)mCategoryRunningSumArrays[j][dataIndex]);
                            rangeCategoryMax[j] = Math.Max(rangeCategoryMax[j], (int)mCategoryRunningSumArrays[j][dataIndex]);
                        }
                        unfilteredMax = Math.Max(unfilteredMax, mUnflilteredRunningSumArrays[dataIndex]);
                    }
                }
            }
        }