예제 #1
0
        public void SeedDb(Store context)
        {
            var precType = new InstrumentType {
                Id             = 1,
                Name           = "Precious",
                InstrumentCode = "PREC"
            };

            context.InstrumentTypes.Add(precType);
            var ingtType = new InstrumentType {
                Id             = 2,
                Name           = "Bullion",
                InstrumentCode = "INGT"
            };

            context.InstrumentTypes.Add(ingtType);

            var precInstr = new Precious {
                Id             = 1,
                InstrumentType = precType,
                Name           = "XAU"
            };

            context.Precious.Add(precInstr);
            var bulInstr = new Bullion {
                Id             = 2,
                InstrumentType = ingtType,
                Name           = "XAU 51572-2000",
                LigatureMass   = 1000,
                BaseInstrument = precInstr
            };

            context.Bullions.Add(bulInstr);
            context.Payments.Add(new PaymentApiModel {
                Id         = 1,
                Amount     = 5000,
                Date       = DateTime.Now,
                Instrument = precInstr
            });
            context.Payments.Add(new PaymentApiModel {
                Id         = 2,
                Amount     = 300,
                Date       = DateTime.Now,
                Instrument = bulInstr
            });
            context.SaveChanges();
        }
예제 #2
0
    void StealPrecious()
    {
        if (!HasTakenPrecious)
        {
            Debug.Log("Stealing my precious!");
            //StopChasePrecious(); // event handlers got this (on owner changed to null)
            Precious.Owner.SendMessage("Kill");
            Precious.Capture(this);

            //Precious = null; // this messed stuff up kinda
            // caused the creation of hastakenprecious bool
            // used for proper ontriggerexit event handling -- needed, prolly not?
            HasTakenPrecious = true;
            //Precious = null;

            // what about instead assigning to Vector3.zero;
            rb.AddForce(-rb.velocity, ForceMode.VelocityChange); // instantly stop our velocity
            // TODO Negate any rotational forces?
        }
        else
        {
            Debug.Log("Already stole my precious!");
        }
    }