Example #1
0
        public BBBase(LinkPos init, float sizeCube, Transform owner)
        {
            Owner = owner;

            UnitPos center = init.Center;

            SizeCube = sizeCube;

            xMin = center.x - SizeCube;
            xMax = center.x + SizeCube;

            yMin = center.y - SizeCube;
            yMax = center.y + SizeCube;

            zMin = center.z - SizeCube;
            zMax = center.z + SizeCube;

            Vertex1 = new UnitPos(xMin, yMin, zMin);
            Vertex2 = new UnitPos(xMax, yMin, zMin);
            Vertex3 = new UnitPos(xMax, yMax, zMin);
            Vertex4 = new UnitPos(xMin, yMax, zMin);
            Vertex5 = new UnitPos(xMin, yMin, zMax);
            Vertex6 = new UnitPos(xMax, yMin, zMax);
            Vertex7 = new UnitPos(xMax, yMax, zMax);
            Vertex8 = new UnitPos(xMin, yMax, zMax);

            ComputeShpereBox();
        }
Example #2
0
        public void Best(LinkPos pos)
        {
            UnitPos center = pos.Center;

            if (center.x - SizeCube < xMin)
            {
                xMin      = center.x - SizeCube;
                Vertex1.x = xMin;
                Vertex4.x = xMin;
                Vertex5.x = xMin;
                Vertex8.x = xMin;
            }
            else if (center.x + SizeCube > xMax)
            {
                xMax      = center.x + SizeCube;
                Vertex2.x = xMax;
                Vertex3.x = xMax;
                Vertex6.x = xMax;
                Vertex7.x = xMax;
            }

            if (center.y - SizeCube < yMin)
            {
                yMin      = center.y - SizeCube;
                Vertex1.y = yMin;
                Vertex2.y = yMin;
                Vertex5.y = yMin;
                Vertex6.y = yMin;
            }
            else if (center.y + SizeCube > yMax)
            {
                yMax      = center.y + SizeCube;
                Vertex3.y = yMax;
                Vertex4.y = yMax;
                Vertex7.y = yMax;
                Vertex8.y = yMax;
            }

            if (center.z - SizeCube < zMin)
            {
                zMin      = center.z - SizeCube;
                Vertex1.z = zMin;
                Vertex2.z = zMin;
                Vertex3.z = zMin;
                Vertex4.z = zMin;
            }
            else if (center.z + SizeCube > zMax)
            {
                zMax      = center.z + SizeCube;
                Vertex5.z = zMax;
                Vertex6.z = zMax;
                Vertex7.z = zMax;
                Vertex8.z = zMax;
            }
            ComputeShpereBox();
        }
Example #3
0
        public virtual void ApplyDmg(int _index, int _dmg)
        {
            LinkPos remove = LinkPosList.ElementAt(_index);

            remove.Life -= _dmg;

            // we don't remove this component, we have life
            if (remove.Life <= 0)
            {
                RemoveAt(_index, ref remove);
            }
        }
Example #4
0
        public virtual bool RemoveAt(int _index, ref LinkPos _remove)
        {
            foreach (KeyValuePair <LinkPos.Neighbor, UnitPos> neigbor in _remove.getNeighbor())
            {
                int invert = (int)neigbor.Key * -1;
                SearchNeigbhor(neigbor.Value, invert, _index, -1);
                SearchNeigbhor(neigbor.Value, invert, _index, 1);
            }

            LinkPosList.RemoveAt(_index);
            _flagRefresh = true;
            return(true);
        }
Example #5
0
        public virtual void SearchNeigbhor(UnitPos lfv, int remove, int idx, int delta)
        {
            if (idx < 0 || idx >= LinkPosList.Count)
            {
                return;
            }

            LinkPos link = LinkPosList.ElementAt(idx);

            if (link.Center == lfv)
            {
                link.Remove((LinkPos.Neighbor)remove);
            }
            else
            {
                SearchNeigbhor(lfv, remove, idx + delta, delta);
            }
        }