Esempio n. 1
0
        public void DoPlayerAction(ACTIONS action)
        {
            if (action == ACTIONS.Hit)
            {
                try
                {
                    Human.AddCardToHand(this.CardDeck.DrawCard());
                }
                catch (DeckEmptyException)
                {
                    for (int i = 0; i < this.BurnDeck.Count; i++)
                    {
                        this.CardDeck.CardStack.Push(this.BurnDeck.Pop());
                    }

                    this.CardDeck.ShuffleDeck();
                }
            }
            else
            {
                ActingPlayer = Dealer;
            }

            if (IsBusted(Human))
            {
                Human.IsBusted = true;
            }
        }
Esempio n. 2
0
 private void radCheckSync_CheckedChanged(object sender, System.EventArgs e)
 {
     if (radCheckSync.Checked)
     {
         action = ACTIONS.ACTION_CHECKSYNC;
     }
 }
Esempio n. 3
0
    void Run()
    {
        // GET THE DISTANCES FROM THE PLAYER AND FROM THE CENTER
        float distancePlayer = Vector3.Distance(player.transform.position, transform.position);
        float distanceCenter = Vector3.Distance(Vector3.zero, transform.position);

        // IF THE PLAYER IS CLOSER THAN THE CENTER THEN RUN TO THE CENTER ELSE RUN TO THE PLAYER
        Vector3 dir;

        if (distancePlayer < distanceCenter)
        {
            dir = Vector3.zero - player.transform.position;
        }
        else
        {
            dir = transform.position - player.transform.position;
        }
        Vector3 velocity = dir.normalized * enemy.moveSpeed;

        rigidB2D.velocity = velocity;

        // WHEN RUN TIMER IS 0 STOP RUNNING
        if (runTimer <= 0)
        {
            runTimer          = 0;
            rigidB2D.velocity = Vector2.zero;
            currentAction     = ACTIONS.SHOOT;
        }

        runTimer -= Time.deltaTime;
    }
Esempio n. 4
0
    void Chase()
    {
        // GET THE DISTANCES FROM THE PLAYER
        float distancePlayer = Vector3.Distance(player.transform.position, transform.position);

        if (distancePlayer <= 0.3)
        {
            rigidB2D.velocity = Vector2.zero;
            enemy.Attack();
        }
        else
        {
            Vector3 dir      = player.transform.position - transform.position;
            Vector3 velocity = dir.normalized * enemy.moveSpeed;
            rigidB2D.velocity = velocity;
        }

        // WHEN RUN TIMER IS 0 STOP RUNNING
        if (chaseTimer <= 0)
        {
            chaseTimer        = 0;
            rigidB2D.velocity = Vector2.zero;
            attackCounter     = attackTime;
            currentAction     = ACTIONS.ATTACK;
        }

        chaseTimer -= Time.deltaTime;
    }
Esempio n. 5
0
    void Update()
    {
        if (Input.GetMouseButtonDown(1))
        {
            if (Physics.Raycast(camera.ScreenPointToRay(Input.mousePosition), out hit_MouseCursor, Mathf.Infinity, 512 /*9: Weg collider*/))
            {
                GoToPoint(hit_MouseCursor.point);
            }
        }

        switch (onAction)
        {
        case ACTIONS.walk:
            //Debug.Log("Gehe in Walk");
            //höchstens eine Frame-Bewegung vom Ziel
            if ((targetPoint - new Vector2(currentUnit.transform.position.x, currentUnit.transform.position.z)).magnitude >= walkSpeed * Time.deltaTime)
            {
                currentUnit.transform.LookAt(new Vector3(targetPoint.x, currentUnit.transform.position.y, targetPoint.y));
                currentUnit.transform.Translate(Vector3.forward * walkSpeed * Time.deltaTime);
                currentUnit.transform.position = new Vector3(currentUnit.transform.position.x, Terrain.activeTerrain.SampleHeight(currentUnit.transform.position), currentUnit.transform.position.z);
            }
            else
            {
                onAction = ACTIONS.idle;     //nach Ankommen auf "idle"-Aktion
            }
            break;
        }
    }
Esempio n. 6
0
        public void DoDealerAction()
        {
            ACTIONS dealerAction = Dealer.GetAction();

            if (dealerAction == ACTIONS.Hit)
            {
                try
                {
                    Dealer.AddCardToHand(this.CardDeck.DrawCard());
                }
                catch (DeckEmptyException)
                {
                    for (int i = 0; i < this.BurnDeck.Count; i++)
                    {
                        this.CardDeck.CardStack.Push(this.BurnDeck.Pop());
                    }

                    this.CardDeck.ShuffleDeck();
                }
            }
            else
            {
                ActingPlayer = Human;
            }

            if (IsBusted(Dealer))
            {
                Dealer.IsBusted = true;
                ActingPlayer    = Human;
            }
        }
Esempio n. 7
0
    void DoAction(GameObject objectAtPoint, Vector3 position)
    {
        Debug.Log("[ActionManager] DoAction");

        bool actionCompleted = false;
        // Track Actions, any objects at point and the incoming position
        switch(CurrentAction)
        {
            case ACTIONS.NONE:
                {
                    break;
                }
            case ACTIONS.SPAWN:
                {
                    actionCompleted = TrySpawn(objectAtPoint, position);
                    break;
                }
            case ACTIONS.SELECT:
                {
                    break;
                }
        }

        if(true == actionCompleted)
        {
            Debug.Log("[ActionManager] Action Completed");

            CurrentAction = ACTIONS.NONE;
        }
    }
Esempio n. 8
0
 public void Insert(List <ActiveUp.Net.Common.DeltaExt.Action> entity)
 {
     using (var dbcontext = new FAXPECContext())
     {
         using (var transaction = dbcontext.Database.BeginTransaction())
         {
             foreach (ActiveUp.Net.Common.DeltaExt.Action a in entity)
             {
                 try
                 {
                     ACTIONS action = DaoSQLServerDBHelper.MapToActionDto(a, true);
                     dbcontext.ACTIONS.Add(action);
                     dbcontext.SaveChanges();
                     a.Id = (decimal)dbcontext.ACTIONS.Select(x => x.ID).DefaultIfEmpty(0).Max();
                 }
                 catch (Exception ex)
                 {
                     transaction.Rollback();
                     if (ex.GetType() == typeof(ManagedException))
                     {
                         ManagedException mEx = new ManagedException(ex.Message, "ACT_ORA004", string.Empty, string.Empty, ex);
                         ErrorLogInfo     er  = new ErrorLogInfo(mEx);
                         log.Error(er);
                         throw mEx;
                     }
                 }
             }
             transaction.Commit();
         }
     }
 }
Esempio n. 9
0
    void Update()
    {
        if (Input.GetMouseButtonDown(1))
        {
            if (Physics.Raycast(camera.ScreenPointToRay(Input.mousePosition), out hit_MouseCursor, Mathf.Infinity, 512/*9: Weg collider*/))
            {
                GoToPoint(hit_MouseCursor.point);
            }
        }

        switch (onAction)
        {
            case ACTIONS.walk:
                //Debug.Log("Gehe in Walk");
                //höchstens eine Frame-Bewegung vom Ziel
                if ((targetPoint - new Vector2(currentUnit.transform.position.x, currentUnit.transform.position.z)).magnitude >= walkSpeed * Time.deltaTime)
                {
                    currentUnit.transform.LookAt(new Vector3(targetPoint.x, currentUnit.transform.position.y, targetPoint.y));
                    currentUnit.transform.Translate(Vector3.forward * walkSpeed * Time.deltaTime);
                    currentUnit.transform.position = new Vector3(currentUnit.transform.position.x, Terrain.activeTerrain.SampleHeight(currentUnit.transform.position), currentUnit.transform.position.z);
                }
                else
                {
                    onAction = ACTIONS.idle; //nach Ankommen auf "idle"-Aktion
                }
                break;
        }
    }
Esempio n. 10
0
 private void BroadcastExcept(ACTIONS action, object data)
 {
     foreach (var c in Sessions.Sessions)
     {
         if (c.ID != ownerID)
         {
             Sessions.SendTo(ConstructMessage(action, data), c.ID);
         }
     }
 }
Esempio n. 11
0
        private string ConstructMessage(ACTIONS action, object data)
        {
            var cc = new ClientMessage();

            cc.action = (int)action;
            cc.data   = data;

            var json = new JavaScriptSerializer().Serialize(cc);

            return(json);
        }
Esempio n. 12
0
 private static void CheckAction(ACTIONS action, float value, bool emit = false)
 {
     if (_pressedActions[action] != value)
     {
         _pressedActions[action] = value;
         if (emit)
         {
             changed(action, (int)value);
         }
     }
 }
Esempio n. 13
0
        public void OnAlarm(StepState state)
        {
            switch (Action)
            {
            case ACTIONS.WALK_LEFT:
                Action = ACTIONS.STAND_LEFT;
                Hero.State.SetAnimation(0, "стоять ", true);
                GridPosition += new Point(-1, 0);
                break;

            case ACTIONS.WALK_RIGHT:
                Action = ACTIONS.STAND_LEFT;
                Hero.State.SetAnimation(0, "стоять ", true);
                GridPosition += new Point(1, 0);
                break;

            case ACTIONS.TO_SIT:
                Action = ACTIONS.SIT;
                VSize  = SIT_HEIGHT;
                break;

            case ACTIONS.FROM_SIT:
                Action = ACTIONS.STAND_LEFT;
                VSize  = HEIGHT;
                break;

            case ACTIONS.SQUAT_LEFT:
                Action        = ACTIONS.SIT;
                GridPosition += new Point(-1, 0);
                break;

            case ACTIONS.SQUAT_RIGHT:
                Action        = ACTIONS.SIT;
                GridPosition += new Point(1, 0);
                break;

            case ACTIONS.GET_DOWN:
                Action        = ACTIONS.HANG_DOWN;
                GridPosition += new Point(0, 2);
                break;

            case ACTIONS.GET_UP:
                Action        = ACTIONS.STAND_LEFT;
                GridPosition += new Point(0, -2);
                break;

            case ACTIONS.JUMP_ON:
                Action        = ACTIONS.HANG_DOWN;
                GridPosition += new Point(0, -2);
                VSpeed        = 0f;
                break;
            }
        }
Esempio n. 14
0
 public void ResetDecisionTimer()
 {
     if (attackCounter <= 0)
     {
         currentAction     = ACTIONS.IDLE;
         rigidB2D.velocity = Vector2.zero;
         decisionTimer     = decisionSpeed;
     }
     else
     {
         attackCounter--;
     }
 }
Esempio n. 15
0
 private void SkinButton_MouseLeave(object sender, EventArgs e)
 {
     if (m_enable == false)
     {
         return;
     }
     if (m_forePress == true)
     {
         return;
     }
     GuiBackground.CreateControlRegion(this, bmp[Common.LEAVE]);
     m_state = ACTIONS.LEAVE;
 }
Esempio n. 16
0
 private void SkinButton_MouseUp(object sender, MouseEventArgs e)
 {
     if (m_enable == false)
     {
         return;
     }
     GuiBackground.CreateControlRegion(this, bmp[Common.UP]);
     m_state = ACTIONS.UP;
     if (pMouseAction != null)
     {
         pMouseAction(ACTIONS.UP);
     }
 }
    public void SetActions(ACTIONS actionA, ACTIONS actionB)
    {
        forwardUI.SetActive(false);
        turnRightUI.SetActive(false);
        turnLeftUI.SetActive(false);
        attackUI.SetActive(false);
        fleeUI.SetActive(false);

        SetAction(actionA, 1);
        action1 = actionA;
        SetAction(actionB, 2);
        action2 = actionB;
        timer.SetActive(true);
    }
Esempio n. 18
0
	public void ProcessActions (){
		Debug.Log("Process Actions");
		if (myAction == ACTIONS.ATTACK_TOWN) {
			AttackTown();
		}

		if (myAction == ACTIONS.LOOK_FOR_RESOURCES) {
			LookForResources();

		}

		myAction = ACTIONS.NONE;

	}
    public void DoAction()
    {
        if (vote < 0)
        {
            selectedAction = action1;
        }
        else if (vote > 0)
        {
            selectedAction = action2;
        }
        else
        {
            if (Random.Range(0, 2) == 0)
            {
                selectedAction = action1;
            }
            else
            {
                selectedAction = action2;
            }
        }



        if (selectedAction == ACTIONS.Forward)
        {
            forwardUI.GetComponent <Animation>().Play("SelectedAction");
            MoveForward();
        }
        else if (selectedAction == ACTIONS.TurnLeft)
        {
            turnLeftUI.GetComponent <Animation>().Play("SelectedAction");
            TurnLeft();
        }
        else if (selectedAction == ACTIONS.TurnRight)
        {
            turnRightUI.GetComponent <Animation>().Play("SelectedAction");
            TurnRight();
        }        /*else if(selectedAction == ACTIONS.Attack){
                  *     attackUI.animation.Play("SelectedAction");
                  *     Attack();
                  * }else if(selectedAction == ACTIONS.Flee){
                  *     fleeUI.animation.Play("SelectedAction");
                  *     Flee();
                  * }*/
        AfterAction();
        maze.SetTileActions();
    }
Esempio n. 20
0
        public void SetSkin(string dir, string name)
        {
            if (File.Exists(dir + name + "_normal.png"))
            {
                bmp[0] = new Bitmap(dir + name + "_normal.png");
            }
            else
            {
                throw (new SystemException("File: " + dir + name + "_normal.png" + " does not exists"));
            }

            if (File.Exists(dir + name + "_enter.png"))
            {
                bmp[1] = new Bitmap(dir + name + "_enter.png");
            }
            else
            {
                throw (new SystemException("File: " + dir + name + "_enter.png" + " does not exists"));
            }

            if (File.Exists(dir + name + "_press.png"))
            {
                bmp[2] = new Bitmap(dir + name + "_press.png");
            }
            else
            {
                throw (new SystemException("File: " + dir + name + "_press.png" + " does not exists"));
            }

            if (File.Exists(dir + name + "_disable.png"))
            {
                bmp[3] = new Bitmap(dir + name + "_disable.png");
                m_enableButtonExists = true;
            }
            else
            {
                m_enableButtonExists = false;
            }


            GuiBackground.CreateControlRegion(this, bmp[0]);
            m_state = ACTIONS.LEAVE;

            this.MouseDown  += SkinButton_MouseDown;
            this.MouseEnter += SkinButton_MouseEnter;
            this.MouseLeave += SkinButton_MouseLeave;
            this.MouseUp    += SkinButton_MouseUp;
        }
Esempio n. 21
0
 private void SkinButton_MouseDown(object sender, MouseEventArgs e)
 {
     if (m_enable == false)
     {
         return;
     }
     if (m_forePress == true)
     {
         return;
     }
     GuiBackground.CreateControlRegion(this, bmp[Common.DOWN]);
     m_state = ACTIONS.DOWN;
     if (pMouseAction != null)
     {
         pMouseAction(ACTIONS.DOWN);
     }
 }
Esempio n. 22
0
        internal static ACTIONS MapToActionDto(ActiveUp.Net.Common.DeltaExt.Action entity, bool isInsert)
        {
            ACTIONS a = new ACTIONS()
            {
                ID_FOLDER_DESTINAZIONE = entity.IdFolderDestinazione,
                NOME_AZIONE            = entity.NomeAzione,
                NUOVO_STATUS           = entity.NuovoStatus,
                TIPO_AZIONE            = entity.TipoAzione,
                ID_NOME_DESTINAZIONE   = (double)entity.IdDestinazione,
                TIPO_DESTINAZIONE      = entity.TipoDestinazione
            };

            if (!isInsert)
            {
                a.ID = (double)entity.Id;
            }
            return(a);
        }
Esempio n. 23
0
 public ActiveUp.Net.Common.DeltaExt.Action GetById(long id)
 {
     ActiveUp.Net.Common.DeltaExt.Action action = null;
     using (var dbcontext = new FAXPECContext())
     {
         try
         {
             ACTIONS a = dbcontext.ACTIONS.Where(x => x.ID == id).FirstOrDefault();
             action = AutoMapperConfiguration.MapToAction(a);
         }
         catch (Exception ex)
         {
             ManagedException mEx = new ManagedException(ex.Message, "ACT_ORA003", string.Empty, string.Empty, ex);
             ErrorLogInfo     er  = new ErrorLogInfo(mEx);
             log.Error(er);
             throw mEx;
         }
         return(action);
     }
 }
Esempio n. 24
0
 public void Insert(ActiveUp.Net.Common.DeltaExt.Action entity)
 {
     using (var dbcontext = new FAXPECContext())
     {
         try
         {
             ACTIONS action = DaoSQLServerDBHelper.MapToActionDto(entity, true);
             dbcontext.ACTIONS.Add(action);
         }
         catch (Exception ex)
         {
             if (ex.GetType() == typeof(ManagedException))
             {
                 ManagedException mEx = new ManagedException(ex.Message, "ACT_ORA001", string.Empty, string.Empty, ex);
                 ErrorLogInfo     er  = new ErrorLogInfo(mEx);
                 log.Error(er);
                 throw mEx;
             }
         }
     }
 }
 public void SetAction(ACTIONS action, int id)
 {
     if (action == ACTIONS.Forward)
     {
         if (id == 1)
         {
             forwardUI.transform.GetChild(0).GetComponent <Image>().color = actionColor1;
         }
         else
         {
             forwardUI.transform.GetChild(0).GetComponent <Image>().color = actionColor2;
         }
         forwardUI.SetActive(true);
     }
     else if (action == ACTIONS.TurnRight)
     {
         if (id == 1)
         {
             turnRightUI.transform.GetChild(0).GetComponent <Image>().color = actionColor1;
         }
         else
         {
             turnRightUI.transform.GetChild(0).GetComponent <Image>().color = actionColor2;
         }
         turnRightUI.SetActive(true);
     }
     else if (action == ACTIONS.TurnLeft)
     {
         if (id == 1)
         {
             turnLeftUI.transform.GetChild(0).GetComponent <Image>().color = actionColor1;
         }
         else
         {
             turnLeftUI.transform.GetChild(0).GetComponent <Image>().color = actionColor2;
         }
         turnLeftUI.SetActive(true);
     }
 }
Esempio n. 26
0
 public void Enable(bool b)
 {
     if (m_enableButtonExists == false)
     {
         return;
     }
     m_enable = b;
     if (b == false)
     {
         GuiBackground.CreateControlRegion(this, bmp[DISABLE]);
         m_state = ACTIONS.DISABLE;
     }
     else
     {
         if (m_state == ACTIONS.LEAVE)
         {
             GuiBackground.CreateControlRegion(this, bmp[Common.LEAVE]);
         }
         if (m_state == ACTIONS.ENTER)
         {
             GuiBackground.CreateControlRegion(this, bmp[Common.ENTER]);
         }
     }
 }
Esempio n. 27
0
    void SelectAction()
    {
        transform.GetChild(0).GetComponent <Animator>().SetBool("Gesture", false);
        // GET DISTANCE FROM PLAYER
        float distance = Vector3.Distance(player.transform.position, transform.position);

        // IF CLOSE TO PLAYER PICK BETWEEN ATTCKING OR RUNNING AWAY
        if (distance <= 0.4)
        {
            int chance = Random.Range(0, 2);
            if (chance == 0)
            {
                attackCounter = attackTime;
                currentAction = ACTIONS.ATTACK;
            }
            else if (chance == 1)
            {
                runTimer      = runTime;
                currentAction = ACTIONS.RUN;
            }
        }
        // IF FAR FROM PLAYER PICK BETWEEN SHOOTING OR CHASING THEM
        else if (distance > 0.4)
        {
            int chance = Random.Range(0, 2);
            if (chance == 0)
            {
                chaseTimer    = chaseTime;
                currentAction = ACTIONS.CHASE;
            }
            else if (chance == 1)
            {
                currentAction = ACTIONS.SHOOT;
            }
        }
    }
Esempio n. 28
0
    public void SetAction(ACTIONS newAction)
    {
        Debug.Log("[ActionManager] SetAction");

        CurrentAction = newAction;
    }
Esempio n. 29
0
 public void GoToPoint(Vector3 newTargetPoint) //in Bewegung setzen, falls keine vorrangige Aktion läuft
 {
     //Debug.Log("Erhalte Befehle (" + ownUnit_OnAction + ") --> Fahre zu " + newTargetPoint);
     onAction    = ACTIONS.walk;
     targetPoint = new Vector2(newTargetPoint.x, newTargetPoint.z);
 }
Esempio n. 30
0
    public IEnumerator do_action(string _ind, ACTIONS action)
    {
        indicator = GameObject.Instantiate (Resources.Load ("Prefabs/" + _ind) as GameObject, transform.position, transform.rotation) as GameObject;
        Vector3 mouse_input = new Vector3 (0, 0, 0);
        Vector3 target_destination = new Vector3 (0, 0, 0);
        bool performed_action = false;
        bool action_success = false;
        int action_range;

        switch (action) {
        case ACTIONS.MOVE:
            action_range = _class.move_range;
            indicator.transform.localScale = new Vector3 (action_range / 2, action_range / 2, action_range / 2);
            break;
        case ACTIONS.ATTACK:
            action_range = _class.attack_range;
            indicator.transform.localScale = new Vector3 (action_range / 3, action_range / 3, action_range / 3);
            break;
        case ACTIONS.SPELL:
            action_range = _class.spell_range;
            indicator.transform.localScale = new Vector3 (action_range / 3, action_range / 3, action_range / 3);
            break;
        default:
            action_range = 5;
            indicator.transform.localScale = new Vector3 (action_range / 3, action_range / 3, action_range / 3);
            break;
        }

        do {
            yield return StartCoroutine(get_input());
            mouse_input = Input.mousePosition;

            Plane playerPlane = new Plane (Vector3.up, transform.position);
            //Ray ray = (GameObject.Find("3D Camera") as Camera).ScreenPointToRay(mouse_input);
            Ray ray = Camera.allCameras [0].ScreenPointToRay (mouse_input);
            RaycastHit hitinfo;
            float hitdist = 0.0f;

            if (Physics.Raycast (ray, out hitinfo, 1 << 8)) {
                target_destination = hitinfo.point;
                // the + .3 is to account for some isometric confusion.
                if (Vector3.Distance (transform.position, target_destination) <= action_range + .3f) {
                    Quaternion targetRotation = Quaternion.LookRotation (target_destination - transform.position);
                    transform.rotation = targetRotation;
                    Collider[] hitColliders;
                    switch (action) {
                    case ACTIONS.ATTACK:
                        hitColliders = Physics.OverlapSphere (target_destination, 1, 1 << 8);
                        if (hitColliders.Length > 0) {
                            foreach (Collider q in hitColliders) {
                                // grabs first unit
                                if (q.GetComponent<Unit> () != null) {
                                    target_unit = q.GetComponent<Unit> ();
                                    break;
                                }
                            }
                            if (target_unit != null) {
                                if (target_unit.gameObject != gameObject) {
                                    performed_action = true;
                                    action_success = true;
                                } else {
                                    print ("failed can't attack self");
                                    performed_action = true;
                                    action_success = false;
                                }
                            } else {
                                print ("failed no units");
                                performed_action = true;
                                action_success = false;
                            }
                        }
                        break;
                    case ACTIONS.SPELL:
                        hitColliders = Physics.OverlapSphere (target_destination, _class.spell.spell_area, 1 << 8);

                        switch (_class.spell.type) {
                        case Spell.TYPE.ALLY:
                            if (hitColliders.Length > 0) {
                                target_units.Clear ();
                                foreach (Collider q in hitColliders) {
                                    Unit q_unit = q.GetComponent<Unit>();
                                    if (q_unit != null && q_unit.team == team) {
                                        target_units.Add (q_unit);
                                        action_success |= true;
                                    } else {
                                        print ("failed, not ally " + q_unit);
                                        action_success |= false;
                                    }
                                }
                                performed_action = true;
                            }
                            break;
                        case Spell.TYPE.ENEMY:
                            if (hitColliders.Length > 0) {
                                target_units.Clear ();
                                foreach (Collider q in hitColliders) {
                                    Unit q_unit = q.GetComponent<Unit>();
                                    if (q_unit != null) {
                                        if (q_unit.team != team) {
                                            target_units.Add (q_unit);
                                            action_success |= true;
                                        } else {
                                            print ("failed, not	enemy " + q_unit);
                                            action_success |= false;
                                        }
                                    } else {
                                        print ("failed, not unit " + q_unit);
                                        action_success |= false;
                                    }
                                }
                                performed_action = true;
                            }
                            break;
                        case Spell.TYPE.SELF:
                            if (hitColliders.Length > 0) {
                                target_units.Clear ();
                                target_units.Add (this);
                                action_success = true;
                                performed_action = true;
                            }
                            break;
                        }
                        break;
                    case ACTIONS.MOVE:
                        action_success = true;
                        break;
                    case ACTIONS.WAIT:
                        action_success = true;
                        break;
                    }

                    performed_action = true;
                }
            }
        } while (!performed_action);

        Destroy (indicator);

        menu_showing = false;

        if (action_success) {
            switch (action) {
            case ACTIONS.MOVE:
                networkView.RPC ("submit_move", RPCMode.Server, target_destination, 1.0f);
                break;
            case ACTIONS.WAIT:
                networkView.RPC ("OnTurnOver", RPCMode.Server);
                current_ap = 0;
                break;
            case ACTIONS.ATTACK:
                attack_target (target_unit);

                if (current_ap > 0) {
                    if (Network.player == owner) {
                        networkView.RPC ("request_set_current_ap", RPCMode.Server, current_ap - 1);
                        show_menu ();
                    }
                    yield return null;
                } else {
                    if (Network.player == owner)
                        networkView.RPC ("OnTurnOver", RPCMode.Server);
                    yield return null;
                }
                break;
            case ACTIONS.SPELL:
                cast_spell_on_target (ref target_units);

                if (current_ap > 0) {
                    if (Network.player == owner) {
                        networkView.RPC ("request_set_current_ap", RPCMode.Server, current_ap - 1);
                        show_menu ();
                    }
                    yield return null;
                } else {
                    if (Network.player == owner)
                        networkView.RPC ("OnTurnOver", RPCMode.Server);
                    yield return null;
                }
                break;
            default:
                break;
            }
        } else {
            if (Network.player == owner)
                show_menu ();
        }
    }
 public void SetAction(ACTIONS act)
 {
     action = act;
 }
 private void Start()
 {
     action = ACTIONS.Quit;
 }
Esempio n. 33
0
        private bool TriggerAction(string key)
        {
            var ret = ACTIONS[key] (this);

            return(ret);
        }
Esempio n. 34
0
 //in Bewegung setzen, falls keine vorrangige Aktion läuft
 public void GoToPoint(Vector3 newTargetPoint)
 {
     //Debug.Log("Erhalte Befehle (" + ownUnit_OnAction + ") --> Fahre zu " + newTargetPoint);
     onAction = ACTIONS.walk;
     targetPoint = new Vector2(newTargetPoint.x, newTargetPoint.z);
 }
Esempio n. 35
0
 public void Step(StepState state)
 {
     if (Alarm > 0)
     {
         Alarm--;
         if (Alarm == 0)
         {
             OnAlarm(state);
         }
     }
     if (Action == ACTIONS.WALK_LEFT)
     {
         Position += new Vector2(-1f / WALK_TIME, 0);
     }
     if (Action == ACTIONS.WALK_RIGHT)
     {
         Position += new Vector2(1f / WALK_TIME, 0);
     }
     if (Action == ACTIONS.STAND_LEFT)
     {
         if (Map[GridPosition + new Point(0, 2)] == Map.EMPTY)
         {
             Action = ACTIONS.FALL;
         }
         else if (state.Keyboard.IsKeyDown(Keys.A) && !Collision(GridPosition + new Point(-1, 0)))
         {
             Action = ACTIONS.WALK_LEFT;
             Alarm  = WALK_TIME;
             Hero.State.SetAnimation(0, "бег", true);
             Hero.Skeleton.FlipX = false;
         }
         else if (state.Keyboard.IsKeyDown(Keys.D) && !Collision(GridPosition + new Point(1, 0)))
         {
             Action = ACTIONS.WALK_RIGHT;
             Alarm  = WALK_TIME;
             Hero.State.SetAnimation(0, "бег", true);
             Hero.Skeleton.FlipX = true;
         }
         else if (state.Keyboard.IsKeyDown(Keys.S))
         {
             Point temp = GridPosition + new Point(0, 2);
             if (Map[temp] == Map.LEFT_SHELF ||
                 Map[temp] == Map.RIGHT_SHELF)
             {
                 Action = ACTIONS.GET_DOWN;
                 Alarm  = GET_DOWN_TIME;
             }
             else
             {
                 Action = ACTIONS.TO_SIT;
                 Alarm  = TO_SIT_TIME;
             }
         }
         else if (state.Keyboard.IsKeyDown(Keys.W))
         {
             Point temp = GridPosition + new Point(0, -2);
             if (Map[temp] == Map.LEFT_SHELF || Map[temp] == Map.RIGHT_SHELF)
             {
                 Action = ACTIONS.JUMP_ON;
                 uint  h = 2u;
                 float t = (float)Math.Sqrt(2f * h / GRAVITY);
                 VSpeed = -GRAVITY * t;
                 Alarm  = (uint)Math.Floor(t);
             }
         }
     }
     if (Action == ACTIONS.JUMP_ON)
     {
         Position += new Vector2(0, VSpeed);
         VSpeed   += GRAVITY;
     }
     if (Action == ACTIONS.GET_DOWN)
     {
         Position += new Vector2(0, 2f / GET_DOWN_TIME);
     }
     if (Action == ACTIONS.TO_SIT)
     {
         VSize -= (HEIGHT - SIT_HEIGHT) / TO_SIT_TIME;
     }
     if (Action == ACTIONS.SIT)
     {
         if (Map[GridPosition + new Point(0, 2)] == Map.EMPTY)
         {
             Action = ACTIONS.FALL;
         }
         else if (state.Keyboard.IsKeyDown(Keys.W) && !Collision(GridPosition))
         {
             Action = ACTIONS.FROM_SIT;
             Alarm  = FROM_SIT_TIME;
         }
         else if (state.Keyboard.IsKeyDown(Keys.A) && !Collision(GridPosition + new Point(-1, 1)))
         {
             Action = ACTIONS.SQUAT_LEFT;
             Alarm  = SQUAT_TIME;
         }
         else if (state.Keyboard.IsKeyDown(Keys.D) && !Collision(GridPosition + new Point(1, 1)))
         {
             Action = ACTIONS.SQUAT_RIGHT;
             Alarm  = SQUAT_TIME;
         }
     }
     if (Action == ACTIONS.HANG_DOWN)
     {
         if (state.Keyboard.IsKeyDown(Keys.S))
         {
             Action = ACTIONS.FALL;
         }
         else if (state.Keyboard.IsKeyDown(Keys.W))
         {
             Action = ACTIONS.GET_UP;
             Alarm  = GET_UP_TIME;
         }
     }
     if (Action == ACTIONS.GET_UP)
     {
         Position += new Vector2(0, -2f / GET_UP_TIME);
     }
     if (Action == ACTIONS.FALL)
     {
         VSpeed    = Math.Min(2, VSpeed + GRAVITY);
         Position += new Vector2(0f, VSpeed);
         if (Position.Y - GridPosition.Y > 1f)
         {
             Vector2 pos = Position;
             GridPosition += new Point(0, 1);
             if (Map[GridPosition + new Point(0, 2)] != Map.EMPTY)
             {
                 VSize  = HEIGHT;
                 Action = ACTIONS.STAND_LEFT;
                 VSpeed = 0f;
             }
             else
             {
                 Position = pos;
             }
         }
     }
     if (Action == ACTIONS.SQUAT_LEFT)
     {
         Position += new Vector2(-1f / SQUAT_TIME, 0);
     }
     if (Action == ACTIONS.SQUAT_RIGHT)
     {
         Position += new Vector2(1f / SQUAT_TIME, 0);
     }
     if (Action == ACTIONS.FROM_SIT)
     {
         VSize += (HEIGHT - SIT_HEIGHT) / FROM_SIT_TIME;
     }
     if (Hero != null)
     {
         Hero.pos = Position;
     }
 }
 private void radSync_CheckedChanged(object sender, System.EventArgs e)
 {
     if (radSync.Checked)
         action = ACTIONS.ACTION_SYNC;
 }
Esempio n. 37
0
 void EnterPressed()
 {
     ACTIONS[_currentOption]();
 }