Example #1
0
    private void OnTriggerStay2D(Collider2D other)
    {
        CosmicBody cosmicBody = other.GetComponent <CosmicBody>();

        if (cosmicBody != null)
        {
            cosmicBody.AddForce(ComputeForce(other.transform));
        }
    }
    public GameObject BuildAsteroid(Vector3 spawnPosition, Vector2 direction)
    {
        Quaternion rotation = Quaternion.Euler(0.0f, 0.0f, Random.Range(0.0f, 360f));
        GameObject obj      = Instantiate(asteroidPrefab, spawnPosition, rotation, asteroidsParent.transform);

        CosmicBody cBody = obj.GetComponent <CosmicBody>();

        cBody.initialVelocity        = direction * Random.Range(initialSpeedThreshold.x, initialSpeedThreshold.y);
        cBody.initialAngularVelocity = Random.Range(0, maxInitialAngularVel);

        return(obj);
    }
        public CosmicBodyViewModel GetCosmicBodyViewModel(CosmicBody body)
        {
            List <Event>        events    = db.Events.Where(e => e.CosmicBody == body.name).Where(e => e.Date > DateTime.Today).ToList();
            CosmicBodyViewModel viewModel = new CosmicBodyViewModel()
            {
                body = body, events = events
            };

            string userId = User.Identity.GetUserId();

            viewModel.userAddress = db.Users.Where(u => u.Id == userId).Select(u => u.Address).FirstOrDefault();
            return(viewModel);
        }
        //public ActionResult GetDetails(string identifier, string type)
        //{
        //    switch (type)
        //    {
        //        case "comet":
        //            return GetCometDetails(identifier);
        //        default:
        //            return Index();
        //    }
        //}

        public ActionResult GetDetails(string identifier, string type, CosmicBody cosmicBody)
        {
            switch (type)
            {
            case "comet":
                return(GetCometDetails(identifier));

            //case "star":
            //    return GetStarDetails(cosmicBody);
            default:
                return(Index());
            }
        }