Exemplo n.º 1
0
        public ConfirmationDialog(string message, behavior onConfirm, behavior onCancel = null)
            : base(Game1.viewport.Width / 2 - (int)Game1.dialogueFont.MeasureString(message).X / 2 - IClickableMenu.borderWidth, Game1.viewport.Height / 2 - (int)Game1.dialogueFont.MeasureString(message).Y / 2, (int)Game1.dialogueFont.MeasureString(message).X + IClickableMenu.borderWidth * 2, (int)Game1.dialogueFont.MeasureString(message).Y + IClickableMenu.borderWidth * 2 + 160)
        {
            if (onCancel == null)
            {
                onCancel = closeDialog;
            }
            else
            {
                this.onCancel = onCancel;
            }
            this.onConfirm = onConfirm;
            Rectangle titleSafeArea = Game1.graphics.GraphicsDevice.Viewport.GetTitleSafeArea();

            message      = Game1.parseText(message, Game1.dialogueFont, Math.Min(titleSafeArea.Width - 64, width));
            this.message = message;
            okButton     = new ClickableTextureComponent("OK", new Rectangle(xPositionOnScreen + width - IClickableMenu.borderWidth - IClickableMenu.spaceToClearSideBorder - 128 - 4, yPositionOnScreen + height - IClickableMenu.borderWidth - IClickableMenu.spaceToClearTopBorder + 21, 64, 64), null, null, Game1.mouseCursors, Game1.getSourceRectForStandardTileSheet(Game1.mouseCursors, 46), 1f)
            {
                myID            = 101,
                rightNeighborID = 102
            };
            cancelButton = new ClickableTextureComponent("OK", new Rectangle(xPositionOnScreen + width - IClickableMenu.borderWidth - IClickableMenu.spaceToClearSideBorder - 64, yPositionOnScreen + height - IClickableMenu.borderWidth - IClickableMenu.spaceToClearTopBorder + 21, 64, 64), null, null, Game1.mouseCursors, Game1.getSourceRectForStandardTileSheet(Game1.mouseCursors, 47), 1f)
            {
                myID           = 102,
                leftNeighborID = 101
            };
            if (Game1.options.SnappyMenus)
            {
                populateClickableComponentList();
                snapToDefaultClickableComponent();
            }
        }
Exemplo n.º 2
0
        public void MoveTo(float dist)
        {
            SetNeuronValue(null, "Done", 0);

            while (Abs(dist) > 0.001)
            {
                behavior newBehavior = new behavior()
                {
                    theBehavior = TheBehavior.Rest
                };
                pending.Add(newBehavior);
                pending.Add(newBehavior);
                float dist1 = 0;
                if (dist > .2f)
                {
                    dist1 = .2f;
                }
                else
                {
                    dist1 = dist;
                }
                dist        = dist - dist1;
                newBehavior = new behavior()
                {
                    theBehavior = TheBehavior.Move,
                    param1      = dist1
                };
                pending.Add(newBehavior);
            }
        }
Exemplo n.º 3
0
        //Random (not currently used)
        public void RandomBehavior()
        {
            //lowest priority...only do this if nothing else is pending
            if (pending.Count > 0)
            {
                return;
            }
            double x = new Random().NextDouble();

            behavior newBehavoir = new behavior()
            {
                theBehavior = TheBehavior.Turn
            };

            newBehavoir.param1 = -(float)PI / 6;
            if (x < .925)
            {
                newBehavoir.param1 = -(float)PI / 12;
            }
            else if (x < .95)
            {
                newBehavoir.param1 = -(float)PI / 24;
            }
            else if (x < .975)
            {
                newBehavoir.param1 = (float)PI / 24;
            }
            else if (x < 1)
            {
                newBehavoir.param1 = (float)PI / 12;
            }

            pending.Add(newBehavoir);
        }
Exemplo n.º 4
0
 void Start()
 {
     blood           = gameObject.GetComponentInChildren <ParticleSystem>();
     agent           = gameObject.GetComponent <NavMeshAgent>();
     currentBehavior = behavior.wander;
     currentHp       = maxHp;
     player          = GameObject.FindGameObjectWithTag("Player");
 }
Exemplo n.º 5
0
    // Use this for initialization
    void Start()
    {
        atual_behavior_ud = behavior.DOWN;
        atual_behavior_lr = behavior.LEFT;

        time_wait_elapsed       = 0;
        time_up_down_elapsed    = 0;
        time_left_right_elapsed = 0;
    }
Exemplo n.º 6
0
        public void TurnTo(Angle theta)
        {
            float x = theta % Rad(90);

            //if (Abs(x) > Rad(1)) //if correction is more than a degree...break
            //{
            //    x = x;
            //}

            SetNeuronValue(null, "Done", 0);

            //don't bother turing more than 180-degrees, turn the other way
            while (theta > PI)
            {
                theta -= (float)PI * 2;
            }
            while (theta < -PI)
            {
                theta += (float)PI * 2;
            }
            float deltaTheta = (float)PI / 6;

            while (Abs(theta) > 0.001)
            {
                float theta1 = 0;
                if (theta > 0)
                {
                    if (theta > deltaTheta)
                    {
                        theta1 = deltaTheta;
                    }
                    else
                    {
                        theta1 = theta;
                    }
                    theta = theta - theta1;
                }
                else
                {
                    if (theta < -deltaTheta)
                    {
                        theta1 = -deltaTheta;
                    }
                    else
                    {
                        theta1 = theta;
                    }
                    theta = theta - theta1;
                }
                behavior newBehavior = new behavior()
                {
                    theBehavior = TheBehavior.Turn,
                    param1      = theta1
                };
                pending.Add(newBehavior);
            }
        }
Exemplo n.º 7
0
    //	coorutina
    IEnumerator MovimientoZombie()
    {
        yield return(new WaitForSeconds(2));

        estado = (behavior)Random.Range(0, 2);
        dir    = Random.Range(0, 4);
        Moving();
        StartCoroutine(MovimientoZombie());
    }
Exemplo n.º 8
0
    void Die()
    {
        agent.enabled   = false;
        currentBehavior = behavior.dead;
        Rigidbody rb = gameObject.GetComponent <Rigidbody>();

        rb.isKinematic = false;
        rb.AddForce((transform.position - player.transform.position).normalized * 35f);
        Destroy(gameObject, 5f);
    }
Exemplo n.º 9
0
 public ServerConnectionDialog(behavior onConfirm = null, behavior onCancel = null)
     : base(Game1.content.LoadString("Strings\\UI:CoopMenu_Connecting"), onConfirm, onCancel)
 {
     okButton.visible = false;
     if (Game1.options.SnappyMenus)
     {
         populateClickableComponentList();
         snapToDefaultClickableComponent();
     }
 }
Exemplo n.º 10
0
 void change_ud()
 {
     if (atual_behavior_ud == behavior.DOWN)
     {
         atual_behavior_ud = behavior.UP;
     }
     else
     {
         atual_behavior_ud = behavior.DOWN;
     }
 }
Exemplo n.º 11
0
            //	coorutina
            IEnumerator MovimientoZombie() //Corrutina para el movimiento del zombie.
            {
                yield return(new WaitForSeconds(3));

                estado = (behavior)Random.Range(0, 3); //Randomizador para la condicion del zombie.
                dir    = Random.Range(0, 4);           //Randomizador para la direccion a moverse.
                rot    = Random.Range(0, 2);           //randomizador para la direccion a rotar.

                Moving();                              //Llamada al metodo de movimiento del zombie.
                StartCoroutine(MovimientoZombie());
            }
Exemplo n.º 12
0
        public override void Fire()
        {
            Init();  //be sure to leave this here to enable use of the na variable
            try
            {
                if (GetNeuronValue(null, "Stop") == 1)
                {
                    Stop();
                }
                if (GetNeuronValue(null, "TurnTo") == 1)
                {
                    TurnTo();
                }
                if (GetNeuronValue(null, "MoveTo") == 1)
                {
                    MoveTo();
                }
                if (GetNeuronValue(null, "Scan") == 1)
                {
                    Scan();
                }
                if (GetNeuronValue(null, "Coll") == 1)
                {
                    Collision();
                }
            }
            catch { return; }

            if (pending.Count == 0)
            {
                SetNeuronValue(null, "Done", 1);
            }


            if (pending.Count != 0)
            {
                behavior currentBehavior = pending[0];
                pending.RemoveAt(0);
                switch (currentBehavior.theBehavior)
                {
                case TheBehavior.Rest: break;

                case TheBehavior.Move:
                    SetNeuronValue("ModuleMove", 1, 2, currentBehavior.param1);
                    break;

                case TheBehavior.Turn:
                    SetNeuronValue("ModuleTurn", 2, 0, currentBehavior.param1);
                    break;
                }
            }
        }
Exemplo n.º 13
0
 public ReadyCheckDialog(string checkName, bool allowCancel, behavior onConfirm = null, behavior onCancel = null)
     : base(Game1.content.LoadString("Strings\\UI:ReadyCheck", "N", "M"), onConfirm, onCancel)
 {
     this.checkName       = checkName;
     this.allowCancel     = allowCancel;
     okButton.visible     = false;
     cancelButton.visible = isCancelable();
     updateMessage();
     exitFunction = delegate
     {
         closeDialog(Game1.player);
     };
     if (Game1.options.SnappyMenus)
     {
         populateClickableComponentList();
         snapToDefaultClickableComponent();
     }
 }
Exemplo n.º 14
0
 void change_lr()
 {
     if (atual_behavior_lr == behavior.LEFT)
     {
         atual_behavior_lr = behavior.WAIT_R;
     }
     if (atual_behavior_lr == behavior.RIGHT)
     {
         atual_behavior_lr = behavior.WAIT_L;
     }
     if (atual_behavior_lr == behavior.WAIT_L)
     {
         atual_behavior_lr = behavior.LEFT;
     }
     if (atual_behavior_lr == behavior.WAIT_R)
     {
         atual_behavior_lr = behavior.RIGHT;
     }
 }
Exemplo n.º 15
0
 public InviteCodeDialog(string code, behavior onClose)
     : base(Game1.content.LoadString("Strings\\UI:Server_InviteCode", code), onClose, onClose)
 {
     this.code = code;
     if (!DesktopClipboard.IsAvailable)
     {
         cancelButton.visible = false;
     }
     else
     {
         onCancel     = copyCode;
         cancelButton = new ClickableTextureComponent("OK", new Rectangle(xPositionOnScreen + width - IClickableMenu.borderWidth - IClickableMenu.spaceToClearSideBorder - 64, yPositionOnScreen + height - IClickableMenu.borderWidth - IClickableMenu.spaceToClearTopBorder + 21, 64, 64), null, null, Game1.mouseCursors, new Rectangle(274, 284, 16, 16), 4f)
         {
             myID           = 102,
             leftNeighborID = 101
         };
     }
     if (Game1.options.SnappyMenus)
     {
         populateClickableComponentList();
         currentlySnappedComponent = getComponentWithID(101);
         snapCursorToCurrentSnappedComponent();
     }
 }
Exemplo n.º 16
0
 public void takeDamage(float amount)
 {
     currentHp      -= amount;
     currentBehavior = behavior.run;
     blood.Emit((int)Random.Range(15f, 25f));
 }