コード例 #1
0
        // 4. Override "GetNewTaskData"
        // Create a 'blank state' on the given goose. Called just before the Task begins running.
        public override GooseTaskData GetNewTaskData(GooseEntity goose)
        {
            HappyOctocatTaskData taskData = new HappyOctocatTaskData();

            taskData.screenHeight = (int)SystemParameters.WorkArea.Height;
            taskData.screenWidth  = (int)SystemParameters.WorkArea.Width;

            Console.WriteLine(taskData.screenHeight + " " + taskData.screenWidth);

            return(taskData);
        }
コード例 #2
0
        // 4. Override "RunTask"
        // Run a frame of this Task on the given goose.
        public override void RunTask(GooseEntity goose)
        {
            // This function is only called when we're the currently running task.
            // The goose's taskData will be of this task's type.
            HappyOctocatTaskData data = (HappyOctocatTaskData)goose.currentTaskData;

            //goose.currentAcceleration = 1000;
            //goose.setSpeed(100);
            int     offsetFromLeft    = 70;
            Vector2 bottomRightCorner = new Vector2(data.screenWidth - offsetFromLeft, data.screenHeight - 150);

            if (Vector2.Distance(bottomRightCorner, goose.rig.bodyCenter) < 100 && Vector2.Distance(bottomRightCorner, goose.rig.bodyCenter) > 30)
            {
                API.Goose.setSpeed(goose, GooseEntity.SpeedTiers.Walk);
                // Set code which stops the octocat from moving if it gets close enough to the poin
                goose.targetPos = bottomRightCorner;
            }
            else if (Vector2.Distance(bottomRightCorner, goose.rig.bodyCenter) >= 100)
            {
                API.Goose.setSpeed(goose, GooseEntity.SpeedTiers.Charge);
                // Set code which stops the octocat from moving if it gets close enough to the poin
                goose.targetPos = bottomRightCorner;
            }
        }