Exemplo n.º 1
0
        /// <summary>Add a point at specified index</summary>
        public void AddPoint(BGCurvePoint point, int index)
        {
            if (index < 0 || index > points.Length)
            {
                print("Unable to add a point. Invalid index: " + index);
                return;
            }
            FireBeforeChange("insert a point");

            points = Insert(points, index, point);


            FireChange(UseEventsArgs ? new BGCurveChangedArgs(this, BGCurveChangedArgs.ChangeTypeEnum.Points) : null);
        }
Exemplo n.º 2
0
 public BGCurveChangedArgs(BGCurve curve, BGCurvePoint point, ChangeTypeEnum changeType) : this(curve, changeType)
 {
     this.point = point;
 }
 /// <summary>all methods, prefixed with Private, are not meant to be called from outside of BGCurve package </summary>
 // this should be called once at creating time
 public void PrivateInit(BGCurvePoint point)
 {
     this.point = point;
     hideFlags  = HideFlags.HideInInspector;
 }
Exemplo n.º 4
0
    public void Spray()
    {
        List <int> allowed_tiles = new List <int>();

        for (int i = 0; i < mc.map_size * mc.map_size; ++i)
        {
            if (mc.units_state[i] == null &&
                mc.map_tiles[i].GetComponent <Tile>().tile_type != "Snow" &&
                mc.map_tiles[i].GetComponent <Tile>().tile_type != "Muddy"
                )
            {
                allowed_tiles.Add(i);
            }
        }

        int index1 = Random.Range(0, allowed_tiles.Count);
        int f1     = allowed_tiles[index1];

        allowed_tiles.Remove(f1);
        int index2 = Random.Range(0, allowed_tiles.Count);
        int f2     = allowed_tiles[index2];

        mc.map_tiles[f1].GetComponent <Tile>().on_fire = true;
        mc.map_tiles[f2].GetComponent <Tile>().on_fire = true;


        fire1 = Instantiate(fire_prefab, transform.position, transform.rotation);
        fire1.GetComponent <Fire>().pos = f1;

        fire2 = Instantiate(fire_prefab, transform.position, transform.rotation);
        fire2.GetComponent <Fire>().pos = f2;


        fire1.GetComponent <Fire>().fire_move();
        fire2.GetComponent <Fire>().fire_move();
        fire_moving = true;

        BGCurve1.GetComponent <BansheeGz.BGSpline.Components.BGCcTrs>().ObjectToManipulate = fire1.transform;
        BGCurve2.GetComponent <BansheeGz.BGSpline.Components.BGCcTrs>().ObjectToManipulate = fire2.transform;


        //move f1
        Vector3 xyPosition = mc.map_tiles[f1].transform.position;
        Vector3 end        = new Vector3(xyPosition.x, xyPosition.y + 0.7f, xyPosition.z - 1.0f);
        Vector3 start      = new Vector3(transform.position.x, transform.position.y, transform.position.z);

        BansheeGz.BGSpline.Curve.BGCurvePoint point1 = BGCurve1.GetComponent <BansheeGz.BGSpline.Curve.BGCurve>().CreatePointFromWorldPosition(
            start, (BansheeGz.BGSpline.Curve.BGCurvePoint.ControlTypeEnum) 1);
        BansheeGz.BGSpline.Curve.BGCurvePoint point2 = BGCurve1.GetComponent <BansheeGz.BGSpline.Curve.BGCurve>().CreatePointFromWorldPosition(
            end, (BansheeGz.BGSpline.Curve.BGCurvePoint.ControlTypeEnum) 1);


        point1.ControlFirstLocal  = new Vector3(0f, 0f);
        point1.ControlSecondLocal = new Vector3(0f, 0f);
        if (start.x > end.x)
        {
            point2.ControlFirstLocal  = new Vector3(0.5f, 4f);
            point2.ControlSecondLocal = new Vector3(-0.5f, -4f);
        }
        else
        {
            point2.ControlFirstLocal  = new Vector3(-0.5f, 4f);
            point2.ControlSecondLocal = new Vector3(0.5f, -4f);
        }
        BGCurve1.GetComponent <BansheeGz.BGSpline.Curve.BGCurve>().Clear();
        BGCurve1.GetComponent <BansheeGz.BGSpline.Curve.BGCurve>().AddPoint(point1);
        BGCurve1.GetComponent <BansheeGz.BGSpline.Curve.BGCurve>().AddPoint(point2);

        BGCurve1.GetComponent <BansheeGz.BGSpline.Components.BGCcTrs>().Distance = 0;


        //move f2
        Vector3 xyPosition2 = mc.map_tiles[f2].transform.position;
        Vector3 end2        = new Vector3(xyPosition2.x, xyPosition2.y + 0.7f, xyPosition2.z - 1.0f);
        Vector3 start2      = new Vector3(transform.position.x, transform.position.y, transform.position.z);

        BansheeGz.BGSpline.Curve.BGCurvePoint point3 = BGCurve2.GetComponent <BansheeGz.BGSpline.Curve.BGCurve>().CreatePointFromWorldPosition(
            start2, (BansheeGz.BGSpline.Curve.BGCurvePoint.ControlTypeEnum) 1);
        BansheeGz.BGSpline.Curve.BGCurvePoint point4 = BGCurve2.GetComponent <BansheeGz.BGSpline.Curve.BGCurve>().CreatePointFromWorldPosition(
            end2, (BansheeGz.BGSpline.Curve.BGCurvePoint.ControlTypeEnum) 1);


        point3.ControlFirstLocal  = new Vector3(0f, 0f);
        point3.ControlSecondLocal = new Vector3(0f, 0f);
        if (start2.x > end2.x)
        {
            point4.ControlFirstLocal  = new Vector3(0.5f, 4f);
            point4.ControlSecondLocal = new Vector3(-0.5f, -4f);
        }
        else
        {
            point4.ControlFirstLocal  = new Vector3(-0.5f, 4f);
            point4.ControlSecondLocal = new Vector3(0.5f, -4f);
        }
        BGCurve2.GetComponent <BansheeGz.BGSpline.Curve.BGCurve>().Clear();
        BGCurve2.GetComponent <BansheeGz.BGSpline.Curve.BGCurve>().AddPoint(point3);
        BGCurve2.GetComponent <BansheeGz.BGSpline.Curve.BGCurve>().AddPoint(point4);

        BGCurve2.GetComponent <BansheeGz.BGSpline.Components.BGCcTrs>().Distance = 0;
    }
Exemplo n.º 5
0
 /// <summary>change point's coordinate to comply to 2d mode</summary>
 public virtual void Apply2D(BGCurvePoint point)
 {
     point.PositionLocal = point.PositionLocal;
     point.ControlFirstLocal = point.ControlFirstLocal;
     point.ControlSecondLocal = point.ControlSecondLocal;
 }
Exemplo n.º 6
0
 /// <summary>Removes a point</summary>
 public void Delete(BGCurvePoint point)
 {
     Delete(IndexOf(point));
 }
Exemplo n.º 7
0
 /// <summary>Add a point to the end</summary>
 public void AddPoint(BGCurvePoint point)
 {
     AddPoint(point, points.Length);
 }
Exemplo n.º 8
0
 /// <summary>Returns a point's index</summary>
 public int IndexOf(BGCurvePoint point)
 {
     return IndexOf(points, point);
 }
Exemplo n.º 9
0
        //=================================================================================
        //                                                    This is not copy/pasted part
        //=================================================================================

        /// <summary>all methods, prefixed with Private, are not meant to be called from outside of BGCurve package </summary>
        //Init with data. No events are fired. point==null for pointsMode switching.
        public void PrivateInit(BGCurvePoint point, BGCurve.PointsModeEnum pointsMode)
        {
            if (point != null)
            {
                // init from new point
                curve          = point.Curve;
                controlType    = point.ControlType;
                pointTransform = point.PointTransform;

                switch (pointsMode)
                {
                case BGCurve.PointsModeEnum.GameObjectsNoTransform:
                    positionLocal      = point.PositionLocal;
                    controlFirstLocal  = point.ControlFirstLocal;
                    controlSecondLocal = point.ControlSecondLocal;
                    break;

                case BGCurve.PointsModeEnum.GameObjectsTransform:
                    transform.localPosition = point.PositionLocal;

                    //transformed locals are always the same
                    var targetTransform = pointTransform != null ? pointTransform : transform;
                    controlFirstLocal  = targetTransform.InverseTransformVector(point.ControlFirstLocalTransformed);
                    controlSecondLocal = targetTransform.InverseTransformVector(point.ControlSecondLocalTransformed);
                    break;

                default:
                    throw new ArgumentOutOfRangeException("pointsMode", pointsMode, null);
                }
            }
            else
            {
                // change pointsMode
                Transform targetTransform;
                switch (pointsMode)
                {
                case BGCurve.PointsModeEnum.GameObjectsNoTransform:
                {
                    if (Curve.PointsMode != BGCurve.PointsModeEnum.GameObjectsTransform)
                    {
                        throw new ArgumentOutOfRangeException("Curve.PointsMode", "Curve points mode should be equal to GameObjectsTransform");
                    }

                    positionLocal = transform.localPosition;

                    //transformed locals are always the same
                    targetTransform = pointTransform != null ? pointTransform : curve.transform;
                    break;
                }

                case BGCurve.PointsModeEnum.GameObjectsTransform:
                {
                    if (Curve.PointsMode != BGCurve.PointsModeEnum.GameObjectsNoTransform)
                    {
                        throw new ArgumentOutOfRangeException("Curve.PointsMode", "Curve points mode should be equal to GameObjectsNoTransform");
                    }

                    transform.position = PositionWorld;

                    //transformed locals are always the same
                    targetTransform = pointTransform != null ? pointTransform : transform;
                    break;
                }

                default:
                    throw new ArgumentOutOfRangeException("pointsMode", pointsMode, null);
                }

                controlFirstLocal  = targetTransform.InverseTransformVector(ControlFirstLocalTransformed);
                controlSecondLocal = targetTransform.InverseTransformVector(ControlSecondLocalTransformed);
            }
        }