public override void Load(GameDataReader reader)
 {
     focalShape       = reader.ReadShapeInstance();
     frequency        = reader.ReadFloat();
     cosOffset        = reader.ReadVector3();
     sinOffset        = reader.ReadVector3();
     previousPosition = reader.ReadVector3();
 }
Exemplo n.º 2
0
 public void Write(ShapeInstance value)
 {
     if (value.isValid)
     {
         writer.Write(value.Shape.SaveIndex);
     }
     else
     {
         writer.Write(-1);
     }
 }
    public void Initialize(Shape shape, Shape focalShape, float radius, float frequency)
    {
        this.focalShape = focalShape;
        this.frequency  = frequency;
        Vector3 orbitAxis = Random.onUnitSphere;

        do
        {
            cosOffset = Vector3.Cross(orbitAxis, Random.onUnitSphere).normalized;
        } while (cosOffset.sqrMagnitude < 0.1f);
        sinOffset  = Vector3.Cross(cosOffset, orbitAxis);
        cosOffset *= radius;
        sinOffset *= radius;

        shape.AddBehavior <RotationShapeBehavior>().AngularVelocity = -360f * frequency * shape.transform.InverseTransformDirection(orbitAxis);
        GameUpdate(shape);
        previousPosition = shape.transform.localPosition;
    }
    //spawn zone에서 motion을 생성해 저정의하는 것은 적절하지 않으므로 여기에 initialize method 정의
    public void Initialize(Shape shape, Shape focalShape, float radius, float frequency)
    {
        this.focalShape = focalShape;
        this.frequency  = frequency;
        Vector3 orbitAxis = Random.onUnitSphere;

        do
        {
            cosOffset = Vector3.Cross(orbitAxis, Random.onUnitSphere).normalized;
        } while (cosOffset.sqrMagnitude < 0.1f);
        sinOffset = Vector3.Cross(cosOffset, orbitAxis);

        cosOffset *= radius;
        sinOffset *= radius;

        //focal shape을 항상 바라보도록 rotation
        shape.AddBehavior <RotationShapeBehavior>().AngularVelocity = -360f * frequency * shape.transform.InverseTransformDirection(orbitAxis);

        GameUpdate(shape);                                //초기 위치를 맞추기 위해 GameUpdate 한번 호출
        previousPosition = shape.transform.localPosition; //focus가 없어지는 것이 첫 프레임일수도 있고, 이전 데이터가 남아있을 수도 있으므로, 초기화
    }
 public void Write(ShapeInstance value)
 {
     writer.Write(value.IsValid ? value.Shape.SaveIndex : -1); //invalid인 shape은 음수 index로
 }
Exemplo n.º 6
0
 public void Write(ShapeInstance value)
 {
     writer.Write(value.IsValid ? value.Shape.SaveIndex : -1);
 }
Exemplo n.º 7
0
 private Bounds GetInstanceBounds(ShapeInstance i)
 {
     return(GetShapeBounds(i.TheShape));
 }
Exemplo n.º 8
0
 public void Write(ShapeInstance value)
 {
     writer.Write(value.Shape.SaveIndex);
 }