コード例 #1
0
 public CharacterRecyclerAdapter(BaseAniDroidActivity context,
                                 IAsyncEnumerable <OneOf <IPagedData <Character>, IAniListError> > enumerable, RecyclerCardType cardType,
                                 Func <Character, CharacterViewModel> createViewModelFunc) : base(context, enumerable, cardType,
                                                                                                  createViewModelFunc)
 {
     ClickAction = (viewModel, position) =>
                   CharacterActivity.StartActivity(Context, viewModel.Model.Id,
                                                   BaseAniDroidActivity.ObjectBrowseRequestCode);
 }
コード例 #2
0
    public CharacterActivity _characterActivity;           //Reference to the character's activity script


    void Awake()
    {
        _UICharacterHeader = null;
        _characterActivity = gameObject.GetComponent <CharacterActivity>();
    }
コード例 #3
0
ファイル: Character.cs プロジェクト: Ystyr/Hierarchy
 public Character () {
     property = new Inventory();
     inventoryActivity = new CharacterActivity<Inventory>();
 }
コード例 #4
0
 //Adds the character activity to the list of those pending one
 public void LogPendingActivity(CharacterActivity characterActivity)
 {
     _characterPendingActivityList.Add(characterActivity);
 }
コード例 #5
0
        //


        public void Update(float dt) // global update function of the application
        {
            updatedt = dt;
            bool controllsenabled = true; // able to walk?

            //manages cooldowns
            if (pickupcooldown > 0)
            {
                pickupcooldown -= dt;
            }
            if (buttoncooldown > 0)
            {
                buttoncooldown -= dt;
            }
            if (Controls_Cooldown > 0)
            {
                Controls_Cooldown -= dt;
            }
            if (End_Of_Level_Cooldown > 0)
            {
                End_Of_Level_Cooldown -= dt;
            }

            if (Controls_Cooldown > 0)
            {
                controllsenabled = false;
            }
            ;

            input = inputadapter.GetInput(inputmechanism); //gets input from inputadapter from current input mechanism

            LatestInput = input;
            // Check if gamepad is enabled


            bool newgamepadonline = input.GamePadOnline; // manages the gamepadonline option: reloads screen when becomes active when in option menu

            if (Gamepadonline != newgamepadonline && screen == 2)
            {
                Gamepadonline = newgamepadonline;
                Reload_screen();
            }
            Gamepadonline = input.GamePadOnline;

            //kill on fall


            Fallable_Object main = GetMain_Character(); // checks if main falls down the screen -> Main_dead();

            if (main != null)
            {
                if (main.position.y + main.size.y > lowestyvalue)
                {
                    Main_Dead();
                }
            }
            // checks if baby falls down the screen -> calls Miain_dead();
            Interacting_Objects.Reset();
            while (Interacting_Objects.GetNext().Visit(() => false, _ => true))
            {
                if (Interacting_Objects.GetCurrent().Visit(() => false, item => { return(item.IsBaby); }))
                {
                    iObject baby = Interacting_Objects.GetCurrent().Visit <iObject>(() => throw new Exception("failed getting interaction"), act => { return(act); });
                    if (baby.position.y + baby.size.y > lowestyvalue)
                    {
                        Main_Dead();
                    }
                }
            }

            bool walk      = false;
            bool CanMove   = false;
            int  walkspeed = 0;

            localwalkspeed += CharacterSpeed * dt; //calculates walkspeed: float -> int: don't lose data!!
            for (int i = (int)(localwalkspeed); i > 0; i--)
            {
                localwalkspeed = localwalkspeed - 1.0f;
                walkspeed++;
            }

            // cursor
            this.Cursor = input.cursor; // reloads cursor position form input

            if (paused == false)        // if game not paused then update the rest
            {
                // walk
                // manages walk on walk input
                WalkDirectionInput walkdirection = WalkDirectionInput.Right;

                if (input.Walk.Visit(() => false, _ => true))
                {
                    walk          = true;
                    walkdirection = input.Walk.Visit <WalkDirectionInput>(() => { throw new Exception("walkdirection failed"); }, item => { return(item); });

                    CanMove = CheckIfMove(dt, walkdirection, walkspeed); // Checks if allowed to move character
                    if (CanMove == false && walkspeed > 1)
                    {
                        for (int i = walkspeed; i > 0 && CanMove == false; i--)
                        {
                            CanMove = CheckIfMove(dt, walkdirection, i); // Checks if allowed to move character
                            if (CanMove == true)
                            {
                                walkspeed = i;
                            }
                        }
                    }
                }


                // handles jump input: if possible :)
                if (controllsenabled == true)
                {
                    if (input.MoveAction.Visit(() => false, _ => true))
                    {
                        if (input.MoveAction.Visit <CharacterMovementAction>(() => { throw new Exception("Charactermovement failed"); }, item => { return(item); }) == CharacterMovementAction.Jump)
                        {
                            if (main != null)
                            {
                                if (main.IsMainCharacter == true)
                                {
                                    main.Jump(this);
                                }
                            }
                        }
                    }
                }

                //handles movement if left/right
                if (controllsenabled == true && walk == true && CanMove == true)
                {
                    if (walkdirection == WalkDirectionInput.Left)
                    {
                        movementchange -= walkspeed;
                    }
                    else if (walkdirection == WalkDirectionInput.Right)
                    {
                        movementchange += walkspeed;
                    }
                }

                // updates stableobjects + make them move if character has to move
                Stable_Objects.Reset();
                while (Stable_Objects.GetNext().Visit(() => false, _ => true))
                {
                    Stable_Objects.GetCurrent().Visit(() => { }, item => { item.Update(dt, this); });

                    if (controllsenabled == true)
                    {
                        if (controllsenabled == true && walk == true && CanMove == true)
                        {
                            Stable_Objects.GetCurrent().Visit(() => { }, item => { item.Move(dt, this, walkdirection, walkspeed); });
                        }
                    }
                }
                // updates fallable objects + make them move if character has to move
                Fallable_Objects.Reset();
                while (Fallable_Objects.GetNext().Visit(() => false, _ => true))
                {
                    Fallable_Objects.GetCurrent().Visit(() => { }, item => { item.Update(dt, this); });

                    if (controllsenabled == true)
                    {
                        if (controllsenabled == true && walk == true && CanMove == true)
                        {
                            Fallable_Objects.GetCurrent().Visit(() => { }, item => { item.Move(dt, this, walkdirection, walkspeed); });
                        }
                    }
                }


                // updates interaction objects + make them move if character has to move
                Interacting_Objects.Reset();
                while (Interacting_Objects.GetNext().Visit(() => false, unusedvalue => true))
                {
                    Interacting_Objects.GetCurrent().Visit(() => { }, item => { item.Update(dt, this); });

                    if (controllsenabled == true)
                    {
                        if (walk == true && CanMove == true)
                        {
                            Interacting_Objects.GetCurrent().Visit(() => { }, item => { item.Move(dt, this, walkdirection, walkspeed); });
                        }
                    }
                }

                // Checking interaction with main character by interacting objects

                List <iObject> interacton = CheckIfMainTouching();

                // checking for baby: picking up when autopickup is on

                if (autopickup == false)
                {
                    if (input.CharacterActivity.Visit(() => false, _ => true))
                    {
                        CharacterActivity activityinput = input.CharacterActivity.Visit <CharacterActivity>(() => throw new Exception("failed getting interaction"), act => { return(act); });
                        if (controllsenabled == true)
                        {
                            if (activityinput == CharacterActivity.Action && pickupcooldown <= 0)
                            {
                                pickupcooldown = 0.5f;
                                if (main != null)
                                {
                                    if (main.HasBaby == false)
                                    {
                                        interacton.Reset();
                                        while (interacton.GetNext().Visit(() => false, unusedvalue => true))
                                        {
                                            if (interacton.GetCurrent().Visit(() => false, item => { return(item.IsBaby); }))
                                            {
                                                // on babypickup...
                                                iObject baby = interacton.GetCurrent().Visit <iObject>(() => throw new Exception("failed getting interaction"), act => { return(act); });
                                                main.HasBaby = true;
                                                baby.Visible = false;
                                                sound_handler.PlayBackground(ChooseBackGroundMusic.game_noncry);
                                                sound_handler.PlaySoundEffect(ChooseSoundEffect.baby_laugh);
                                            }
                                        }
                                    }


                                    else
                                    {
                                        // on babydrop...
                                        Interacting_Objects.Reset();
                                        while (Interacting_Objects.GetNext().Visit(() => false, unusedvalue => true))
                                        {
                                            if (Interacting_Objects.GetCurrent().Visit(() => false, item => { return(item.IsBaby); }))
                                            {
                                                iObject baby = Interacting_Objects.GetCurrent().Visit <iObject>(() => throw new Exception("failed getting interaction"), act => { return(act); });
                                                main.HasBaby  = false;
                                                baby.position = new Position(main.position.x, main.position.y + 20);
                                                baby.Visible  = true;
                                                sound_handler.PlayBackground(ChooseBackGroundMusic.game_cry);
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }

                // checking if touching items


                interacton.Reset();
                while (interacton.GetNext().Visit(() => false, unusedvalue => true))
                {
                    // killing main character when touching object is deadly
                    iObject TouchingObject = interacton.GetCurrent().Visit <iObject>(() => throw new Exception("failed getting interaction"), act => { return(act); });

                    if (TouchingObject.IsDeadly)
                    {
                        Main_Dead();
                    }

                    // picking baby up when autopickup is on
                    if (TouchingObject.IsBaby)
                    {
                        if (autopickup == true)
                        {
                            if (main.HasBaby == false)
                            {
                                main.HasBaby           = true;
                                TouchingObject.Visible = false;
                                sound_handler.PlayBackground(ChooseBackGroundMusic.game_noncry);
                                sound_handler.PlaySoundEffect(ChooseSoundEffect.baby_laugh);
                            }
                        }
                    }

                    // when the main character reaches the end
                    if (TouchingObject.IsEnd)
                    {
                        //then the main character is carying the baby...
                        if (main.HasBaby)
                        {
                            //on levelend
                            main.HasBaby               = false;
                            TouchingObject.HasBaby     = true;
                            this.End_Of_Level_Cooldown = 3;
                            this.Controls_Cooldown     = 3;
                            this.End_Of_Level          = true;
                            sound_handler.PlaySoundEffect(ChooseSoundEffect.game_end);
                        }
                    }
                }
            }
            // update our gui_stuff: buttons and labels
            Gui_stuff.Reset();
            while (Gui_stuff.GetNext().Visit(() => false, unusedvalue => true))
            {
                Gui_stuff.GetCurrent().Visit(() => { }, item => { item.Update(dt, this); });
            }

            // when end animation is over: load next level
            if (End_Of_Level_Cooldown <= 0 && End_Of_Level == true)
            {
                End_Of_Level_Cooldown = 0;
                End_Of_Level          = false;
                Controls_Cooldown     = 0;
                Create_screen(main.nextscreen);
            }
        }