protected virtual void Initialize()
    {
        rb                   = GetComponent <Rigidbody> ();
        courseIndex          = 0;
        target               = course [courseIndex];
        shouldBrake          = false;
        shouldBoost          = false;
        useBankingModifier   = false;
        remainingBoostTime   = 0.0f;
        remaingBoostCooldown = 0.0f;
        isPlayer             = false;
        myRenderer           = this.GetComponent <Renderer> ();
        originalMaterial     = myRenderer.material;
        gl                   = this.GetComponent <GoalHandler> ();
        isSpeedPowerUpActive = false;

        currentHealth = startingHealth;
        engineSound   = this.GetComponent <AudioSource> ();
        canBeDamaged  = true;
        respawnIndex  = 0;
        respawnPoint  = this.transform.position;
        rs            = RacerState.PreRace;

        if (gl)
        {
            foreach (GameObject g in course)
            {
                if (g.tag == "goal")
                {
                    gl.SetInitialTarget(g);
                    break;
                }
            }
        }
    }
Exemple #2
0
        public static void LoadLevel()
        {
            //Clear Entities
            EntityHandler.entities.Clear();

            //Create Goal Handler
            EntityHandler.entities.Add(new GoalHandler());
            GoalHandler goalHandler = (GoalHandler)EntityHandler.entities[0];

            for (int i = 0; i < rawMapData.Split(':')[1].Split(';').Length; i++)
            {
                String[] rawData = rawMapData.Split(':')[1].Split(';')[i].Split(',');

                switch (rawData[0])
                {
                case "player":
                    EntityHandler.entities.Add(new Player(float.Parse(rawData[1]) * Camera.gameScale / .53f, float.Parse(rawData[2]) * Camera.gameScale / .53f));
                    //Console.WriteLine("Player Created");
                    break;

                case "platform":
                    EntityHandler.entities.Add(new Platform(
                                                   float.Parse(rawData[1]) * Camera.gameScale / .53f,
                                                   float.Parse(rawData[2]) * Camera.gameScale / .53f,
                                                   float.Parse(rawData[3]) * Camera.gameScale / .53f,
                                                   float.Parse(rawData[4]) * Camera.gameScale / .53f));
                    //Console.WriteLine("Platform Created");
                    break;

                case "goal":
                    goalHandler.createGoal(float.Parse(rawData[1]) * Camera.gameScale / .53f, float.Parse(rawData[2]) * Camera.gameScale / .53f);
                    //Console.WriteLine("Goal Created");
                    break;

                case "arrow1":
                    EntityHandler.entities.Add(new Arrow(
                                                   float.Parse(rawData[1]) * Camera.gameScale / .53f,
                                                   float.Parse(rawData[2]) * Camera.gameScale / .53f,
                                                   1));
                    break;

                case "arrow2":
                    EntityHandler.entities.Add(new Arrow(
                                                   float.Parse(rawData[1]) * Camera.gameScale / .53f,
                                                   float.Parse(rawData[2]) * Camera.gameScale / .53f,
                                                   2));
                    break;

                case "arrow3":
                    EntityHandler.entities.Add(new Arrow(
                                                   float.Parse(rawData[1]) * Camera.gameScale / .53f,
                                                   float.Parse(rawData[2]) * Camera.gameScale / .53f,
                                                   3));
                    break;
                }
            }
        }
Exemple #3
0
        void Update()
        {
            playerGeometryTransform.position = Vector3.Lerp(playerGeometryTransform.position, transform.position, lerp * Time.deltaTime);

            if (Input.GetKeyDown(KeyCode.LeftArrow) || Input.GetKeyDown(KeyCode.A))
            {
                if (!Physics.Raycast(new Ray(transform.position, -transform.right), 1))
                {
                    transform.position += -transform.right;
                }
            }
            if (Input.GetKeyDown(KeyCode.RightArrow) || Input.GetKeyDown(KeyCode.D))
            {
                if (!Physics.Raycast(new Ray(transform.position, transform.right), 1))
                {
                    transform.position += transform.right;
                }
            }
            if (Input.GetKeyDown(KeyCode.UpArrow) || Input.GetKeyDown(KeyCode.W))
            {
                if (!Physics.Raycast(new Ray(transform.position, transform.forward), 1))
                {
                    transform.position += transform.forward;
                }
            }
            if (Input.GetKeyDown(KeyCode.DownArrow) || Input.GetKeyDown(KeyCode.S))
            {
                if (!Physics.Raycast(new Ray(transform.position, -transform.forward), 1))
                {
                    transform.position += -transform.forward;
                }
            }

            if (goalHandler != null && Vector3.SqrMagnitude(goalPosition - playerGeometryTransform.transform.position) < 0.5f)
            {
                goalHandler();
                goalHandler = null;
            }
        }
Exemple #4
0
        public async Task <IHttpActionResult> create(Models.GoalChecklistModel model)
        {
            if (!ModelState.IsValid)
            {
                return(Json(new { error = true, message = Models.ErrorMessage.getErrorMessage(ModelState) }));
            }
            Boolean result = true;

            //string[] date = model.startDate.Split('/');
            try
            {
                Goal goal = new Goal();
                goal.goalName    = model.goalName;
                goal.description = model.description;
                // goal.startDate = DateTime.Parse(date[1] + "/" + date[0] + "/" + ( Convert.ToInt32(date[2])+543));
                goal.startDate  = model.startDate;
                goal.endDate    = model.endDate;
                goal.categoryID = model.categoryID;
                goal.circleID   = model.circleID;
                goal.userID     = User.Identity.GetUserId();
                goal.circleType = model.circleType;
                goal.flag       = model.flag;

                System.Web.HttpContext.Current.Application.Lock();
                _db.Goals.Add(goal);
                int isSave = _db.SaveChanges();
                if (isSave == 1)
                {
                    Goal g = _db.Goals.Where(p => p.goalName == model.goalName).FirstOrDefault();

                    List <DAL.Checklist> cList = new List <DAL.Checklist>();
                    foreach (var c in model.checklists)
                    {
                        DAL.Checklist checklist = new DAL.Checklist();
                        checklist.checklistName = c.value;
                        checklist.goalID        = g.id;
                        cList.Add(checklist);
                    }
                    _db.Checklists.AddRange(cList);
                    _db.SaveChanges();

                    List <GoalHandler> ghList = new List <GoalHandler>();


                    if (model.users != null)
                    {
                        foreach (var u in model.users)
                        {
                            GoalHandler gh = new GoalHandler();
                            gh.userID = u;
                            gh.goalID = g.id;
                            _db.GoalHandlers.Add(gh);
                            _db.SaveChanges();

                            var c = from cl in _db.Checklists where cl.goalID.Equals(g.id) select cl;
                            List <ChecklistProgress> clpList = new List <ChecklistProgress>();
                            foreach (var clp in c)
                            {
                                ChecklistProgress checklistProgress = new ChecklistProgress();
                                checklistProgress.checklistProgress1 = 1;
                                checklistProgress.time          = DateTime.Now;
                                checklistProgress.checklistID   = clp.id;
                                checklistProgress.goalHandlerID = gh.id;
                                clpList.Add(checklistProgress);
                            }
                            _db.ChecklistProgresses.AddRange(clpList);
                        }
                    }
                    else
                    {
                        GoalHandler gh = new GoalHandler();
                        gh.userID = User.Identity.GetUserId();
                        gh.goalID = g.id;
                        _db.GoalHandlers.Add(gh);
                        _db.SaveChanges();

                        var c = from cl in _db.Checklists where cl.goalID.Equals(g.id) select cl;
                        List <ChecklistProgress> clpList = new List <ChecklistProgress>();
                        foreach (var clp in c)
                        {
                            ChecklistProgress checklistProgress = new ChecklistProgress();
                            checklistProgress.checklistProgress1 = 1;
                            checklistProgress.time          = DateTime.Now;
                            checklistProgress.checklistID   = clp.id;
                            checklistProgress.goalHandlerID = gh.id;
                            clpList.Add(checklistProgress);
                        }
                        _db.ChecklistProgresses.AddRange(clpList);
                    }

                    _db.SaveChanges();
                }
                System.Web.HttpContext.Current.Application.UnLock();
            }
            catch (Exception e)
            {
                return(Json(e.Message));
            }

            return(Json(new { result = result }));
        }
Exemple #5
0
        public async Task <IHttpActionResult> update(Models.GoalChecklistModel model)
        {
            if (!ModelState.IsValid)
            {
                return(Json(new { error = true, message = Models.ErrorMessage.getErrorMessage(ModelState) }));
            }
            Boolean result = true;

            try
            {
                System.Web.HttpContext.Current.Application.Lock();

                var goal = _db.Goals.Where(p => p.id == model.id).FirstOrDefault();
                goal.goalName    = model.goalName;
                goal.description = model.description;
                goal.startDate   = model.startDate;
                goal.endDate     = model.endDate;
                goal.categoryID  = model.categoryID;
                goal.circleID    = model.circleID;
                goal.userID      = User.Identity.GetUserId();
                goal.circleType  = model.circleType;


                System.Web.HttpContext.Current.Application.Lock();
                _db.SaveChanges();

                {
                    Goal g = _db.Goals.Where(p => p.id == model.id).FirstOrDefault();

                    var checklists = from cl in _db.Checklists where cl.goalID.Equals(g.id) select cl;
                    var checkused  = 0;
                    foreach (var checklist in checklists)
                    {
                        var checklistPs = from clp in _db.ChecklistProgresses where clp.checklistID.Equals(checklist.id) select clp;

                        foreach (var checklistP in checklistPs)
                        {
                            if (checklistP.checklistProgress1 == 2)
                            {
                                checkused = 1;
                                break;
                            }
                        }
                    }
                    if (checkused == 0)
                    {
                        foreach (var checklist in checklists)
                        {
                            var checklistPs = from clp in _db.ChecklistProgresses where clp.checklistID.Equals(checklist.id) select clp;
                            foreach (var checklistP in checklistPs)
                            {
                                _db.ChecklistProgresses.Remove(checklistP);
                            }
                            _db.Checklists.Remove(checklist);
                        }

                        var goalHandlers = from gh in _db.GoalHandlers where gh.goalID.Equals(g.id) select gh;
                        foreach (var goalHandler in goalHandlers)
                        {
                            _db.GoalHandlers.Remove(goalHandler);
                        }
                        _db.SaveChanges();
                    }

                    List <DAL.Checklist> cList = new List <DAL.Checklist>();

                    foreach (var c in model.checklists)
                    {
                        DAL.Checklist checklist = new DAL.Checklist();
                        checklist.checklistName = c.value;
                        checklist.goalID        = g.id;
                        cList.Add(checklist);
                    }
                    _db.Checklists.AddRange(cList);
                    _db.SaveChanges();

                    List <GoalHandler> ghList = new List <GoalHandler>();


                    if (model.users != null)
                    {
                        foreach (var u in model.users)
                        {
                            GoalHandler gh = new GoalHandler();
                            gh.userID = u;
                            gh.goalID = g.id;
                            _db.GoalHandlers.Add(gh);
                            _db.SaveChanges();

                            var c = from cl in _db.Checklists where cl.goalID.Equals(g.id) select cl;
                            List <ChecklistProgress> clpList = new List <ChecklistProgress>();
                            foreach (var clp in c)
                            {
                                ChecklistProgress checklistProgress = new ChecklistProgress();
                                checklistProgress.checklistProgress1 = 1;
                                checklistProgress.time          = DateTime.Now;
                                checklistProgress.checklistID   = clp.id;
                                checklistProgress.goalHandlerID = gh.id;
                                clpList.Add(checklistProgress);
                            }
                            _db.ChecklistProgresses.AddRange(clpList);
                        }
                    }
                    else
                    {
                        GoalHandler gh = new GoalHandler();
                        gh.userID = User.Identity.GetUserId();
                        gh.goalID = g.id;
                        _db.GoalHandlers.Add(gh);
                        _db.SaveChanges();

                        var c = from cl in _db.Checklists where cl.goalID.Equals(g.id) select cl;
                        List <ChecklistProgress> clpList = new List <ChecklistProgress>();
                        foreach (var clp in c)
                        {
                            ChecklistProgress checklistProgress = new ChecklistProgress();
                            checklistProgress.checklistProgress1 = 2;
                            checklistProgress.time          = DateTime.Now;
                            checklistProgress.checklistID   = clp.id;
                            checklistProgress.goalHandlerID = gh.id;
                            clpList.Add(checklistProgress);
                        }
                        _db.ChecklistProgresses.AddRange(clpList);
                    }

                    _db.SaveChanges();
                }
                System.Web.HttpContext.Current.Application.UnLock();
            }
            catch (Exception e)
            {
                return(Json(e.Message));
            }

            return(Json(new { result = result }));
        }
Exemple #6
0
 // Use this for initialization
 void Awake()
 {
     m_goalHandlerScript = GetComponent <GoalHandler>();
 }
Exemple #7
0
 public void setGoal(Vector3 goalPosition, GoalHandler handler)
 {
     this.goalHandler    = handler;
     this.goalPosition   = goalPosition;
     this.goalPosition.y = 2.75f;
 }
Exemple #8
0
 void OnClick()
 {
     GoalHandler.LoadLevelSelect();
 }
Exemple #9
0
            public void Start()
            {
                Console.WriteLine($"{FirstTeam.Name} против {SecondTeam.Name}");
                int t1 = 0;
                int t2 = 0;

                for (int i = 1; i < 30; i++)
                {
                    switch (random.Next(1, 10))
                    {
                    case 1:
                        if (Referi.Preference != Referi.Preferences.ForFirst)
                        {
                            FailHandler.Invoke(FirstTeam, " игра рукой");
                        }
                        break;

                    case 2:
                        if (Referi.Preference != Referi.Preferences.ForSecond)
                        {
                            FailHandler.Invoke(SecondTeam, " игра рукой");
                        }
                        break;

                    case 3:
                        if (Winner() == SecondTeam.Name)
                        {
                            GoalHandler.Invoke(SecondTeam);
                            t2++;
                        }
                        else
                        {
                            if (Winner() == FirstTeam.Name)
                            {
                                GoalHandler.Invoke(FirstTeam);
                                t1++;
                            }
                            else
                            {
                                if (random.Next(1, 100) % 2 == 0)
                                {
                                    GoalHandler.Invoke(SecondTeam);
                                    t2++;
                                }
                                else
                                {
                                    GoalHandler.Invoke(FirstTeam);
                                    t1++;
                                }
                            }
                        }
                        break;

                    case 4:
                        try
                        {
                            switch (random.Next(1, 5))
                            {
                            case 1:
                                throw new GameExeption("На стадионе бомба", 12);

                            case 2:
                                throw new GameExeption("Зависла система", 3);
                            }
                        }
                        catch (GameExeption ex)
                        {
                            Console.WriteLine($"Чп: {ex.Message}, матч перенесен на {ex.Overtime} ч. Данные счета были потеряны");
                            t1 = 0;
                            t2 = 0;
                        }
                        break;
                    }
                }
                if (random.Next(0, 100) % 2 == 0)
                {
                    AdditionalHandler.Invoke(random.Next(1, 11));
                }
                Console.WriteLine($"Матч завершился со счетом {t1}:{t2}");
                using (StreamWriter sr = new StreamWriter("Games.txt", true))
                {
                    sr.WriteLine($"{FirstTeam.Name}|{SecondTeam.Name}|{t1}:{t2}");
                }
            }