override public void UseHoop(GameObject obj, RecordPosition record, bool direction)
 {
     base.UseHoop(obj, record, direction);
     GetComponent <AudioSource>().Play();
     if (obj.GetComponent <NumberInfo>())
     {
         AlgebraInfo ai = obj.GetComponent <AlgebraInfo>();
         if (!direction)
         {
             if (ai)
             {
                 ai.SetExponent(ai.exponent - 1);
                 if (ai.exponent == 0)
                 {
                     Destroy(ai);
                     return;
                 }
             }
         }
         else
         {
             if (!ai)
             {
                 ai = obj.AddComponent <AlgebraInfo>();
                 ai.SetExponent(1);
             }
             else
             {
                 ai.SetExponent(ai.exponent + 1);
             }
         }
     }
 }
 void Start()
 {
     if (!gameObject.GetComponent <RecordPosition>())
     {
         gameObject.AddComponent <RecordPosition>();
     }
     rp = gameObject.GetComponent <RecordPosition>();
     ps = gameObject.GetComponent <ParticleSystem>();
 }
    public override void UseHoop(GameObject obj, RecordPosition record, bool direction)
    {
        if (!ObjectIsCloseToSurface(obj))
        {
            // Prevents objects from getting flipped when being taken out of inventory, or created, INSIDE the sphere.
            return;
        }
        if (LevelBuilder.inst.levelBuilderIsShowing)
        {
            return;
        }
        base.UseHoop(obj, record, direction);
        NumberModifier.ModifyOperation nmf = (x => x);

        if (frac.numerator == -1 && frac.denominator == 1)
        {
            nmf             = (x => Fraction.Multiply(x, frac));
            currentEquation = " * " + frac;
        }
        else
        {
            if (direction)
            {
                nmf             = (x => Fraction.Multiply(x, frac));
                currentEquation = " * " + frac;
            }
            else
            {
                nmf             = (x => Fraction.Multiply(x, Fraction.Inverse(frac)));
                currentEquation = " / " + frac;
            }
        }

//		// commented Debug.Log("2");
        if (obj.tag == "Player")
        {
//			PlayerInventory.inst.ModifyInventoryItemnmf);
            Inventory.inst.ModifyInventoryItems(nmf);
        }
        else if (obj.GetComponent <NumberInfo>() != null && obj.GetComponent <ResourceNumber>() == null)
        {
            NumberInfo ni = obj.GetComponent <NumberInfo>();
            modifyOp = nmf;
//			// commented Debug.Log("3");
            ModifyNumber(ni);
        }

//		obj.SendMessage("OnNumberChanged",SendMessageOptions.DontRequireReceiver);
    }
Beispiel #4
0
    public virtual void Init()
    {
        if (initialized)
        {
            return;
        }
        initialized = true;
        rp          = GetComponent <RecordPosition>();

        SetUpLineMaterial();
        SetUpFriends();

        SetNumber(fraction);
//		// commented Debug.Log("init;"+name);
        PlayerGadgetController.inst.gadgetThrow.onPlayerThrow += OnPlayerThrow;
    }
    public override void UseHoop(GameObject obj, RecordPosition record, bool direction)
    {
        if (LevelBuilder.inst.levelBuilderIsShowing)
        {
            return;
        }
        base.UseHoop(obj, record, direction);
        NumberInfo ni = obj.GetComponent <NumberInfo>();

        Player p = obj.GetComponent <Player>();

        // Set number only if player is holding it.
        if (p)
        {
            if (PlayerGadgetController.inst.ThrowGadgetEquipped())
            {
                if (GadgetThrow.inst.numberHeld)
                {
                    ni = GadgetThrow.inst.numberHeld.GetComponent <NumberInfo>();
                }
            }
        }

        if (ni)
        {
            if (ni.IsSoapable())
            {
                if (direction)
                {
                    ni.SoapNumber();
                }
                else
                {
                    ni.UnSoapNumber();
                }
            }
        }

        if (p)
        {
            GadgetThrow.inst.UpdateAmmoGraphics();
        }
    }
Beispiel #6
0
    virtual public void UseHoop(GameObject obj, RecordPosition record, bool direction)
    {
        if (LevelBuilder.inst.levelBuilderIsShowing)
        {
            return;
        }
        //// commented Debug.Log(record.lastPosition);
        record.nowPosition  = obj.transform.position;
        record.lastPosition = obj.transform.position;         // Do this to avoid any double triggering

        if (obj.GetComponent <Collider>().enabled == false)
        {
            return;                                                      // still works on player!
        }
        AudioManager.inst.PlayShortBop(transform.position);
        EffectsManager.inst.CreateRingEffect2(transform.position, 1, .5f, Color.white);
        Vector3 fxPos = obj == Player.inst.gameObject ? obj.transform.position + Vector3.up * 2 : obj.transform.position;         // player fx need to be offset up as players position is on the ground, vs a number passing through position is in the center

        EffectsManager.inst.CreateSmallPurpleExplosion(fxPos, 1.5f, .4f);
    }
Beispiel #7
0
//
    public void CheckCrossing(Collider other)
    {
//		// commented Debug.Log("check:"+other.name);
        RecordPosition record = other.GetComponent <RecordPosition>();

        if (record == null)
        {
            return;
        }


        GameObject obj       = other.gameObject;
        Vector3    pastPoint = transform.InverseTransformPoint(record.lastPosition);
        Vector3    nowPoint  = transform.InverseTransformPoint(other.transform.position);

//		// commented Debug.Log("pp,np:"+pastPoint+","+nowPoint);

        // resource number exceptions
        if (other.GetComponent <ResourceNumber>())
        {
            other.GetComponent <Rigidbody>().AddForce(Vector3.Normalize(pastPoint - nowPoint) * 50);        // bounce off
            return;
        }

        if (pastPoint.z < 0 && nowPoint.z >= 0)
        {
//			WebGLComm.inst.DebugOrange("Hoop trigger forwards:"+other.name);
            UseHoop(obj, record, true);
        }
        else if (pastPoint.z >= 0 && nowPoint.z < 0)
        {
//			Debug.Log("Backwards! - " + obj.name);
//			WebGLComm.inst.DebugOrange("Hoop trigger backwards:"+other.name);
            UseHoop(obj, record, false);
        }
        else
        {
//			WebGLComm.inst.DebugOrange("Hoop trigger neither:"+other.name);
//			Debug.Log("neither!:"+nowPoint+","+pastPoint);
        }
    }
Beispiel #8
0
 virtual public void Start()
 {
     // todos possible memory leak
     energyNumber.energyNumberDestroyedDelegate += EnergyNumberDestroyed;
     if (vehicleRigidbody)
     {
         vehicleRigidbody.isKinematic = true;
     }
     if (!rp)
     {
         rp = vehicleRigidbody.GetComponent <RecordPosition>();
     }
     if (GetComponentInChildren <MouseLook>())
     {
         GetComponentInChildren <MouseLook>().enabled = false;
     }
     if (!aud)
     {
         aud = GetComponent <AudioSource>();
     }
 }
Beispiel #9
0
 override public void UseHoop(GameObject obj, RecordPosition record, bool direction)
 {
     base.UseHoop(obj, record, direction);
     if (obj.GetComponent <NumberInfo>())
     {
         if (!direction)
         {
             if (obj.GetComponent <EnergyBall>())
             {
                 obj.GetComponent <EnergyBall>().RemoveEnergyBallProperties();
             }
         }
         else
         {
             GetComponent <AudioSource>().Play();
             if (!obj.GetComponent <EnergyBall>())
             {
                 obj.AddComponent <EnergyBall>();
             }
             obj.GetComponent <EnergyBall>().AddEnergyBallProperties();
         }
     }
 }
 public float deltaPosPerFrameToAchieveMaxRotation = 1f;     // approx 30 m/s
 void Start()
 {
     r  = GetComponent <Rotate>();
     rp = GetComponent <RecordPosition>();
 }
 void Start()
 {
     rp = this.gameObject.AddComponent <RecordPosition>();
 }
Beispiel #12
0
 void Start()
 {
     ps = GetComponentInChildren <ParticleSystem>();
     rp = Player.inst.GetComponent <RecordPosition>();
 }
 void Start()
 {
     rp = !!GetComponent <RecordPosition> () ? GetComponent <RecordPosition> () : gameObject.AddComponent <RecordPosition> ();
 }
Beispiel #14
0
 void Start()
 {
     rp = GetComponent <RecordPosition> ();
 }
Beispiel #15
0
 void Start()
 {
     ni0 = GetComponent <NumberInfo>();        // all arrows are numberinfo .. should probably inherit?
     rp  = GetComponent <RecordPosition>();
 }