Exemplo n.º 1
0
 void Dispense()
 {
     if (pc_hp.power <= 0 && gotItem)
     {
         position = transform.position;
         if (spriteRenderer.flipX)
         {
             position.x -= 0.2f;
         }
         else if (!spriteRenderer.flipX)
         {
             position.x += 0.2f;
         }
         consumable = Instantiate(item, position, transform.rotation);
         if (consumable.gameObject.name == "Power(Clone)")
         {
             consumable.gameObject.name = "Power";
         }
         ItemFloat dropping = consumable.GetComponent <ItemFloat>();
         dropping.dropTime     = 2;
         dropping.dropStrength = Vector2.down * 10;
         dropping.dropped      = false;
         gotItem = false;
     }
     else if (pc_hp.power > 0 && !gotItem)
     {
         gotItem = true;
     }
 }
Exemplo n.º 2
0
 // Update is called once per frame
 void Update()
 {
     if (crashed.transform.position == spawnCheck)
     {
         startup = true;
     }
     if (startup)
     {
         player = GameObject.FindWithTag("Player");
         pc_hp  = player.GetComponent <PlayerHealth>();
         Dispense();
     }
     if (!gotItem)
     {
         if (consumable.transform.position.y < -10)
         {
             Destroy(consumable);
             consumable = Instantiate(item, position, transform.rotation);
             ItemFloat dropping = consumable.GetComponent <ItemFloat>();
             dropping.dropTime     = 2;
             dropping.dropStrength = Vector2.down * 10;
             dropping.dropped      = false;
         }
     }
 }
Exemplo n.º 3
0
    // Use this for initialization
    void Start()
    {
        spriteRenderer = GetComponent <SpriteRenderer>();
        cutscene       = GameObject.FindWithTag("Spawn");
        crashed        = cutscene.GetComponent <Crashland>();
        spawnCheck     = new Vector3(-1.5f, 1.5f, 0);
        position       = transform.position;
        if (spriteRenderer.flipX)
        {
            position.x -= 0.2f;
        }
        else if (!spriteRenderer.flipX)
        {
            position.x += 0.2f;
        }
        consumable = Instantiate(item, position, transform.rotation);
        if (consumable.gameObject.name == "Power(Clone)")
        {
            consumable.gameObject.name = "Power";
        }
        ItemFloat dropping = consumable.GetComponent <ItemFloat>();

        dropping.dropTime     = 2;
        dropping.dropStrength = Vector2.down * 10;
        dropping.dropped      = false;
    }
Exemplo n.º 4
0
    protected override Item GetCloned()
    {
        var key = new ItemFloat(value, time)
        {
            inTangent  = inTangent,
            outTangent = outTangent,
            inWeight   = inWeight,
            outWeight  = outWeight
        };

        return(key);
    }
Exemplo n.º 5
0
    public static Vector2 GetOutHandle(ItemFloat key, ItemFloat nextKey)
    {
        var adjacentOut = key.outWeight * (nextKey.time - key.time);
        var oppositeOut = key.outTangent * adjacentOut;

        var handleOut = new Vector2(
            key.time + adjacentOut,
            key.value + oppositeOut
            );

        return(handleOut);
    }
Exemplo n.º 6
0
    public static Vector2 GetInHandle(ItemFloat prevKey, ItemFloat key)
    {
        var adjacentIn = key.inWeight * (key.time - prevKey.time);
        var oppositeIn = key.inTangent * adjacentIn;

        var handleIn = new Vector2(
            key.time - adjacentIn,
            key.value - oppositeIn
            );

        return(handleIn);
    }
Exemplo n.º 7
0
    public override Item InterpolateLinearlyTo(Item key, float t)
    {
        if (cashedKeyFloat == null)
        {
            cashedKeyFloat = new ItemFloat(value, t);
        }

        cashedKeyFloat.time = t;
        var portion = Mathf.InverseLerp(time, key.time, t);

        cashedKeyFloat.value = Mathf.Lerp(value, (key as ItemFloat).value, portion);

        return(cashedKeyFloat);
    }
Exemplo n.º 8
0
    public override Item InterpolateByBezierTo(Item key, float t)
    {
        var targetKey = key as ItemFloat;

        if (cashedKeyFloat == null)
        {
            cashedKeyFloat = new ItemFloat(value, t);
        }

        var handleA = GetOutHandle(this, targetKey);
        var handleB = GetInHandle(this, targetKey);
        var portion = Mathf.InverseLerp(time, key.time, t);

        cashedKeyFloat.value = BezierCubic(portion, value, handleA.y, handleB.y, targetKey.value);

        return(cashedKeyFloat);
    }