コード例 #1
0
    //加载TransForm和颜色
    public override void Load(GameDataReader reader)
    {
        base.Load(reader);
        if (reader.Version >= 5)
        {
            LoadColors(reader);
        }
        else
        {
            SetColor(reader.Version > 0 ? reader.ReadColor() : Color.white);
        }

        if (reader.Version >= 6)
        {
            Age = reader.ReadFloat();
            int behaviorCount = reader.ReadInt();
            for (int i = 0; i < behaviorCount; i++)
            {
                //AddBehavior((ShapeBehaviorType)reader.ReadInt()).Load(reader);
                ShapeBehavior behavior = ((ShapeBehaviorType)reader.ReadInt()).GetInstance();
                behaviorList.Add(behavior);
                behavior.Load(reader);
            }
        }
        else if (reader.Version >= 4)
        {
            AddBehavior <RotationShapeBehavior>().AngularVelocity = reader.ReadVector();
            AddBehavior <MovementShapeBehavior>().Velocity        = reader.ReadVector();
        }
    }
コード例 #2
0
 public override void Load(GameDataReader reader)
 {
     base.Load(reader);
     if (reader.Version >= 5) // Runs unique functions for a specific save file type
     {
         LoadColors(reader);
     }
     else
     {
         SetColor(reader.Version > 0 ? reader.ReadColor() : Color.white); // If the save file type supports colour saving, read the colour data, otherwise colour the object white
     }
     if (reader.Version >= 6)                                             // Runs unique functions for a specific save file type
     {
         Age = reader.ReadFloat();
         int behaviorCount = reader.ReadInt();
         for (int i = 0; i < behaviorCount; i++)
         {
             ShapeBehavior behavior = ((ShapeBehaviorType)reader.ReadInt()).GetInstance(); // Identifies shapeBehaviour from index in save file, and adds it to the shape's behaviour list
             behaviorList.Add(behavior);
             behavior.Load(reader);
         }
     }
     else if (reader.Version >= 4)                                                     // Runs unique functions for a specific save file type
     {
         AddBehavior <RotationShapeBehavior>().AngularVelocity = reader.ReadVector3(); // Adds functions to move and rotate object based on data in the save file
         AddBehavior <MovementShapeBehavior>().Velocity        = reader.ReadVector3();
     }
 }
コード例 #3
0
    public override void Load(GameDataReader reader)
    {
        base.Load(reader);

        // If the version is 5 or higher SetColor for each element
        if (reader.Version >= 5)
        {
            LoadColors(reader);
        }
        else
        {
            // If the version is 1 read color, otherwise use white
            SetColor(reader.Version > 0 ? reader.ReadColor() : Color.white);
        }

        // Reads its identifier integer, cast it to ShapeBehaviorType, invoke AddBehavior and then load the rest behaviors
        if (reader.Version >= 6)
        {
            Age = reader.ReadFloat();
            int behaviorCount = reader.ReadInt();

            for (int i = 0; i < behaviorCount; i++)
            {
                ShapeBehavior behavior = ((ShapeBehaviorType)reader.ReadInt()).GetInstance();
                behaviorList.Add(behavior);
                behavior.Load(reader);
            }
        }
        // If is old use the old code
        else if (reader.Version >= 4)
        {
            AddBehavior <RotationShapeBehavior>().AngularVelocity = reader.ReadVector3();
            AddBehavior <MovementShapeBehavior>().Velocity        = reader.ReadVector3();
        }
    }
コード例 #4
0
 void Start()
 {
     ShapeBehavior original = (ShapeBehavior)ShapeManager.GetComponent(typeof(ShapeBehavior));
     shapebehavior = (ShapeBehavior)Instantiate (original);
     shapebehavior.alto = alto;
     shapebehavior.ancho = ancho;
     shapebehavior.bloqueName = "EnemyBlock";
     invsnap = 1 / snapval;
     camera_height = transform.parent.camera.orthographicSize;
     figures = createDebugFigures ();
 }
コード例 #5
0
    public override void Load(GameDataReader reader)
    {
        base.Load(reader);
        LoadColors(reader);

        Age = reader.ReadFloat();
        int behaviorCount = reader.ReadInt();

        for (int i = 0; i != behaviorCount; ++i)
        {
            ShapeBehavior behavior = ((ShapeBehaviorType)reader.ReadInt()).GetInstance();
            behaviorList.Add(behavior);
            behavior.Load(reader);
        }
    }
コード例 #6
0
    public override void Load(GameDataReader reader)
    {
        base.Load(reader);
        LoadColors(reader);

        Age = reader.ReadFloat();
        int behaviorCount = reader.ReadInt();

        for (int i = 0; i < behaviorCount; i++)
        {
            //add behavior and load behavior parameters
            ShapeBehavior behavior = ((ShapeBehaviorType)reader.ReadInt()).GetInstance();
            behaviorList.Add(behavior);
            behavior.Load(reader);
        }
    }