Example #1
0
    void OnTriggerEnter(Collider other)
    {
        if (other.tag == "Player")
        {
            player        = other.gameObject.GetComponent <BasicCharacter> ();
            playerInRange = true;

            if (player.keyType == keyType)
            {
                useKeyDialogue.text = "Press SPACE to use key";
            }
            if (keyType == KeyType.None)
            {
                useKeyDialogue.text = "There is a key inserted into the slot";
            }
            if (player.keyType != keyType && player.keyType != KeyType.None)
            {
                useKeyDialogue.text = "This key doesn't fit";
            }
            if (player.keyType == KeyType.None && keyType != KeyType.None)
            {
                useKeyDialogue.text = "There seems to be a slot for a key";
            }

            useKeyDialogue.color = WHITE;
        }
    }
Example #2
0
    public override void _Ready()
    {
        var characters = GetTree().GetNodesInGroup("main_character");

        if (characters != null)
        {
            _mainCharacter = characters[0] as BasicCharacter;
        }
    }
Example #3
0
        static void Main(string[] args)
        {
            var character =
                new BasicCharacter(
                    new NowCause().WrapWithPause(2),
                    new ActionBehavior <SingleValueEffect <DateTime> >(eff => Console.WriteLine("Hello, World! At {0}", eff.Value)));

            character.Start();
        }
Example #4
0
 public void TryInteract(BasicCharacter character)
 {
     if (CanInteract)
     {
         CanInteract = false;
         GetParent().RemoveChild(this);
         character.GetCarryAttachPoint().AddChild(this);
         SetPosition(new Vector2());
     }
 }
    private void _onBodyEntered(Godot.Object body)
    {
        if (UseAreaTrigger)
        {
            BasicCharacter character = body as BasicCharacter;

            if (character != null)
            {
                FadeIn();
            }
        }
    }
Example #6
0
    public override void _Ready()
    {
        _area           = GetNode("Area2D") as Area2D;
        _tooltip        = GetNode("interact_tooltip") as InteractTooltip;
        _globals        = GetNode("/root/Globals") as Globals;
        _fireplaceLight = GetNode("fireplace_light") as Light2D;

        var characters = GetTree().GetNodesInGroup("main_character");

        if (characters != null)
        {
            _mainCharacter = characters[0] as BasicCharacter;
        }
    }
Example #7
0
    public void TryInteract(BasicCharacter character)
    {
        if (character.FuelHeld)
        {
            IFuel fuel = character.HeldObject as IFuel;
            if (fuel != null)
            {
                _globals.FireplaceHealth += fuel.GetFuelAmount();
            }

            character.DestroyHeldObject();
            _tooltip.FadeOut();
        }
    }
Example #8
0
 public void Ctor_NullRandom_Throws()
 {
     Assert.Throws <ArgumentNullException>(() =>
     {
         _ = new BasicCharacter(
             "velocity",
             "design",
             12,
             new StatSet(),
             new MoveSet(),
             new Ability(),
             null);
     });
 }
Example #9
0
    public void TryInteract(BasicCharacter character)
    {
        if (CanInteract)
        {
            if (TooltipEnabled)
            {
                InteractTooltip tooltip = GetNode(TooltipPath) as InteractTooltip;

                tooltip?.FadeOut();
            }

            CanInteract = false;
            character.PickupObject(this);
        }
    }
Example #10
0
    void Start()
    {
        mazeManager = GameObject.Find("Maze").GetComponent <MazeManager> ();
        mob         = GetComponent <NavMeshAgent> ();
        mob.speed   = walkSpeed;
        animator.SetBool("Patrol", true);
        lastMaze = mazeManager.currentMaze;

        player = GameObject.FindWithTag("Player").GetComponent <BasicCharacter>();

        SetAllPaths();

        currentPatrolPath = GetPatrolPath();
        senseCollider     = GetComponent <SphereCollider> ();

        GotoNextPoint();
    }
Example #11
0
    void OnTriggerEnter(Collider other)
    {
        if (other.tag == "Player")
        {
            player = other.gameObject.GetComponent <BasicCharacter>();
            pickupDialogue.color = WHITE;

            if (player.keyType == KeyType.None)
            {
                pickupDialogue.text = "Press SPACE to pickup key";
                playerInRange       = true;
            }
            else
            {
                pickupDialogue.text = "You can only carry one key at a time";
            }
        }
    }
Example #12
0
    public void TryInteract(BasicCharacter character)
    {
        if (character.FuelHeld)
        {
            IFuel fuel = character.HeldObject as IFuel;
            if (fuel != null)
            {
                _globals.NewFireplaceHealth += fuel.GetFuelAmount();

                if (!Lit)
                {
                    _animationPlayer.Play("flash");
                }
            }

            character.DestroyHeldObject();
            _tooltip.FadeOut();
        }
    }
Example #13
0
    public override void _Ready()
    {
        HeatSpeed = 0.0f;

        _area           = GetNode("Area2D") as Area2D;
        _tooltip        = GetNode("interact_tooltip") as InteractTooltip;
        _globals        = GetNode("/root/Globals") as Globals;
        _fireplaceLight = GetNode("fireplace_light") as Light2D;

        _veins           = GetNode("veins") as Sprite;
        _glow            = GetNode("glow") as Sprite;
        _hearth          = GetNode("hearth") as Sprite;
        _animationPlayer = GetNode("AnimationPlayer") as AnimationPlayer;

        var characters = GetTree().GetNodesInGroup("main_character");

        if (characters != null)
        {
            _mainCharacter = characters[0] as BasicCharacter;
        }
    }
Example #14
0
    public void Initialize(Transform anchorRef)
    {
        // Create The Players
        GameObject tmpPlayer1 = Instantiate(Resources.Load<GameObject>("Prefabs/PlayerObjects/Player")) as GameObject;
        tmpPlayer1.name = "Player1";
        tmpPlayer1.transform.position = new Vector3(-5, 0, 0);
        //tmpPlayer1.AddComponent<Hadouken>();

        GameObject tmpPlayer2 = Instantiate(Resources.Load<GameObject>("Prefabs/PlayerObjects/Player")) as GameObject;
        tmpPlayer2.name = "Player2";
        tmpPlayer2.transform.position = new Vector3(5, 0, 0);

        // Create the UI
        GameObject BottomBarGO = Instantiate(Resources.Load<GameObject>("Prefabs/BottomBar/BottomBar")) as GameObject;
        BottomBarGO.transform.SetParent(anchorRef, false);
        BottomBarRef = BottomBarGO.GetComponent<BottomBar>();

        List<Ability> abilities = new List<Ability>();

        List<Action> HadoukenActions = new List<Action>(){new Blast(tmpPlayer1)};
        Ability Hadouken = new Ability("Hadouken");
        Hadouken.Actions = HadoukenActions;
        abilities.Add(Hadouken);

        List<Action> bigMidHitActions = new List<Action>(){new CreateSquare(tmpPlayer1)};
        Ability bigMidHit = new Ability("Slash");
        bigMidHit.Actions = bigMidHitActions;
        abilities.Add(bigMidHit);

        BottomBarRef.Initialize(tmpPlayer1, abilities);
        GameObject TopBarGO = Instantiate(Resources.Load<GameObject>("Prefabs/BottomBar/TopBar")) as GameObject;
        TopBarGO.transform.SetParent(anchorRef, false);

        // Finally initialize the Players
        Player1 = tmpPlayer1.AddComponent<BasicCharacter>();
        Player1.Initialize(TopBarGO, true, 20, abilities);

        Player2 = tmpPlayer2.AddComponent<BasicCharacter>();
        Player2.Initialize(TopBarGO, false, 20, new List<Ability>());
    }
Example #15
0
        /// <summary>
        /// Creates characters for the game.
        /// </summary>
        /// <param name="random">The random number generator.</param>
        /// <param name="actionHistory">The action history.</param>
        /// <param name="userInput">The user input.</param>
        private static IEnumerable <Character> CreateCharacters(
            IRandom random,
            ActionHistory actionHistory,
            IUserInput userInput)
        {
            var playerStats = new StatSet
            {
                Attack  = new Stat(5),
                Defence = new Stat(4),
                Speed   = new Stat(4),
            };

            var playerMoves =
                new MoveSetBuilder()
                .WithMove(
                    new MoveBuilder()
                    .Name("Sword Strike")
                    .Describe("The user swings their sword to inflict damage. This move has increased priority.")
                    .WithMaxUses(15)
                    .WithPriority(1)
                    .SuccessDecreasesLinearlyWithUses(100, 25, 10, random, MoveUseResult.Failure, actionHistory)
                    .WithAction(
                        new DamageActionBuilder()
                        .WithBasePower(20, random)
                        .UserSelectsSingleEnemy(userInput)
                        .Build()
                        )
                    .Build()
                    )
                .WithMove(
                    new MoveBuilder()
                    .Name("Insistent Jab")
                    .Describe("This attack's base power increases with each consecutive successful use.")
                    .WithMaxUses(15)
                    .WithAccuracy(100, random)
                    .WithAction(
                        new DamageActionBuilder()
                        .BasePowerIncreasesLinearlyWithUses(20, 5, random, actionHistory)
                        .UserSelectsSingleEnemy(userInput)
                        .Build()
                        )
                    .Build()
                    )
                .WithMove(
                    new MoveBuilder()
                    .Name("Retaliate")
                    .Describe("The user deals 1.5x the damage of the last attack it received.")
                    .WithMaxUses(5)
                    .AlwaysSucceeds()
                    .WithAction(
                        new DamageActionBuilder()
                        .PercentageOfLastReceivedMoveDamage(150, actionHistory)
                        .Retaliates(actionHistory)
                        .Build()
                        )
                    .Build()
                    )
                .WithMove(
                    new MoveBuilder()
                    .Name("Restore")
                    .Describe("The user drinks a potion to restore 20 health, while also increasing their protect limit by one.")
                    .WithMaxUses(10)
                    .AlwaysSucceeds()
                    .WithAction(
                        new HealActionBuilder()
                        .WithAmount(20)
                        .AbsoluteHealing()
                        .TargetsUser()
                        .Build()
                        )
                    .WithAction(
                        new ProtectLimitChangeActionBuilder()
                        .WithAmount(1)
                        .TargetsUser()
                        .Build()
                        )
                    .Build()
                    )
                .Build();

            var player = new Player(
                userInput,
                "Warrior",
                "a",
                100,
                playerStats,
                playerMoves);

            player.EquipItem(
                new ItemBuilder()
                .Name("Might Relic")
                .Describe("Increases the holder's Attack by 5% at the end of each turn.")
                .WithEndTurnAction(
                    new BuffActionBuilder()
                    .TargetsUser()
                    .WithRaiseAttack(0.05)
                    .Build()
                    )
                .Build()
                );

            var bardStats = new StatSet
            {
                Attack  = new Stat(4),
                Defence = new Stat(3),
                Speed   = new Stat(4),
            };

            var bardMoves =
                new MoveSetBuilder()
                .WithMove(
                    new MoveBuilder()
                    .Name("Play Music")
                    .Describe("The user shreds on their guitar to inflict 5 damage on all enemies.")
                    .WithMaxUses(25)
                    .WithAccuracy(100, random)
                    .WithAction(
                        new DamageActionBuilder()
                        .AbsoluteDamage(5)
                        .TargetsEnemies()
                        .Build()
                        )
                    .Build()
                    )
                .Build();

            var bard = new BasicCharacter("Bard", "a", 100, bardStats, bardMoves, random);

            bard.EquipItem(
                new ItemBuilder()
                .Name("Capo")
                .Describe("Makes the holder's music better, increasing the power of their attacks by 1.")
                .WithDamagePowerTransform(p => p + 1)
                .Build()
                );

            var mageStats = new StatSet
            {
                Attack  = new Stat(6),
                Defence = new Stat(3),
                Speed   = new Stat(5),
            };

            var mageMoves =
                new MoveSetBuilder()
                .WithMove(
                    new MoveBuilder()
                    .Name("Magic Missile")
                    .Describe("The user fires a spectral missile to inflict 20 damage.")
                    .WithMaxUses(15)
                    .WithAccuracy(100, random)
                    .WithAction(
                        new DamageActionBuilder()
                        .AbsoluteDamage(20)
                        .TargetsFirstEnemy()
                        .Build()
                        )
                    .Build()
                    )
                .WithMove(
                    new MoveBuilder()
                    .Name("Lightning Bolt")
                    .Describe("The user summons a lightning strike to deal damage equal to 30% of the target's health.")
                    .WithMaxUses(5)
                    .WithAccuracy(70, random)
                    .WithAction(
                        new DamageActionBuilder()
                        .PercentageDamage(30)
                        .TargetsFirstEnemy()
                        .Build()
                        )
                    .Build()
                    )
                .WithMove(
                    new MoveBuilder()
                    .Name("Meditate")
                    .Describe("The user finds inner calm to raise the Defence stat of all characters on their team.")
                    .WithMaxUses(10)
                    .AlwaysSucceeds()
                    .WithAction(
                        new BuffActionBuilder()
                        .TargetsTeam()
                        .WithRaiseDefence(0.1)
                        .Build()
                        )
                    .Build()
                    )
                .WithMove(
                    new MoveBuilder()
                    .Name("Refresh")
                    .Describe("The user regenerates 30% of their max health.")
                    .WithMaxUses(10)
                    .AlwaysSucceeds()
                    .WithAction(
                        new HealActionBuilder()
                        .WithAmount(30)
                        .PercentageHealing()
                        .TargetsUser()
                        .Build()
                        )
                    .Build()
                    )
                .Build();

            var mage = new BasicCharacter("Mage", "b", 100, mageStats, mageMoves, random);

            mage.EquipItem(
                new ItemBuilder()
                .Name("Rolling Wave")
                .Describe("Deals 6 damage to another random character at the start of the holder's turn.")
                .WithStartTurnAction(
                    new DamageActionBuilder()
                    .AbsoluteDamage(6)
                    .TargetsRandomOther(random)
                    .Build()
                    )
                .Build()

                );

            var rogueStats = new StatSet
            {
                Attack  = new Stat(3),
                Defence = new Stat(2),
                Speed   = new Stat(3),
            };

            var rogueMoves =
                new MoveSetBuilder()
                .WithMove(
                    new MoveBuilder()
                    .Name("Protect")
                    .Describe("The user protects themself from the next move.")
                    .WithMaxUses(5)
                    .WithPriority(2)
                    .AlwaysSucceeds()
                    .WithAction(
                        new ProtectActionBuilder()
                        .TargetsFirstAlly()
                        .Build()
                        )
                    .Build()
                    )
                .Build();

            var rogue = new BasicCharacter("Rogue", "b", 80, rogueStats, rogueMoves, random);

            return(new Character[] { player, bard, mage, rogue });
        }
Example #16
0
 /// <summary>
 /// This method adds a racer to the racer list.
 /// </summary>
 /// <param name="racer">The racer to add,
 ///                     of type BasicCharacter</param>
 public void AddRacer(BasicCharacter racer)
 {
     _racers.Add(racer);
 }
Example #17
0
    /// <summary>
    /// This method processes the racers positions.
    /// </summary>
    private void ProcessPosition()
    {
        _indexCompare     = 1;     // Starting compare index
        _currentCharacter = null;  // Resetting current character
        _isPlayerShown    = false; // Player position has not
                                   // been shown

        // Loop for going through all the characters
        while (_indexCompare < _racersToArray.Length)
        {
            // Storing current character for comparison
            _currentCharacter = _racersToArray[_indexCompare];

            _indexSearch = _indexCompare - 1; // Getting starting
                                              // index for compare

            // Loop for comparing and checking if the character
            // is less than the current character
            while (_indexSearch >= 0 &&
                   _racersToArray[_indexSearch]
                   .CompareTo(_currentCharacter) == -1)
            {
                // Swaping the characters
                _racersToArray[_indexSearch + 1]
                    = _racersToArray[_indexSearch];

                _indexSearch--; // Getting another character to
                                // compare to
            }

            // Putting current character at the right order
            _racersToArray[_indexSearch + 1] = _currentCharacter;

            _indexCompare++; // Getting another character to
                             // compare to
        }

        // Checking if models has been assigned to the character
        if (_racersToArray[0].ModelInfo != null &&
            _isShowCrown)
        {
            // Setting the crown on a new leader
            _racersToArray[0].ModelInfo.SetCrown(_leaderCrown);
        }
        // Condition for starting to show the crown
        else
        {
            _isShowCrown = true;
        }

        // Loop to show the first 3 character positions including the player
        for (int i = 0; i < _racersToArray.Length; i++)
        {
            // Condition to show first 2 positions
            if (i < 2)
            {
                // Checking if the player is in first 2 positions
                if (!_isPlayerShown &&
                    _racersToArray[i].CharacterName ==
                    GameData.Instance.PlayerName)
                {
                    MainCanvasUI.Instance
                    .SetInGameRacePosition(i, true,
                                           _racersToArray[i].CharacterName);

                    _isPlayerShown = true;
                }
                else // Showing other characters positions
                {
                    //TODO: Show character's name
                    MainCanvasUI.Instance
                    .SetInGameRacePosition(i, false,
                                           _racersToArray[i].CharacterName);
                }
            }
            // Condition for showing the player's position if NOT shown
            else if (!_isPlayerShown)
            {
                // Finding the player's character
                if (_racersToArray[i].CharacterName ==
                    GameData.Instance.PlayerName)
                {
                    //TODO: Show player's name
                    MainCanvasUI.Instance
                    .SetInGameRacePosition(i, true,
                                           _racersToArray[i].CharacterName);

                    break;
                }
            }
            // Condition for already showing the player's position
            // and now needs to show 1 more character position
            else
            {
                //TODO: Show character's name
                MainCanvasUI.Instance
                .SetInGameRacePosition(i, false,
                                       _racersToArray[i].CharacterName);

                break;
            }
        }

        // Condition to check if to show the end screen
        if (_isShowEndScreen)
        {
            // Setting the end screen race position
            MainCanvasUI.Instance.SetEndScreenPosition();

            // Showing the end screen
            MainCanvasUI.Instance.SetEndScreenUI(true);

            // Condition to play winner sfx
            if (_racersToArray[0].CharacterName
                == GameData.Instance.PlayerName)
            {
                AudioManager.Instance.PlayWinner();
            }

            // Condition to play loser sfx
            else
            {
                AudioManager.Instance.PlayLoser();
            }

            _isShowEndScreen = false; // End screen shown
        }

        _isProcessing = false; // Processing done
    }
Example #18
0
 private void Start()
 {
     this.BasicCharacterInfo = this.GetComponent<BasicCharacter>();
 }
Example #19
0
        static void Main(string[] args)
        {
            Character character = new BasicCharacter();

            Console.WriteLine("Choose a difficulty:");
            Console.WriteLine("1.Hard; 2.Normal; 3.Easy");
            string difficulty = Console.ReadLine();

            Console.WriteLine("Choose a level:");
            string level = Console.ReadLine();
            MakeEventDifficulty eventMaker;

            switch (difficulty)
            {
            case "1":
                eventMaker = new MakeEventHard(level);
                break;

            case "2":
                eventMaker = new MakeEventNormal(level);
                break;

            default:
                eventMaker = new MakeEventEasy(level);
                break;
            }

            eventMaker.add(character);
            int endAt = Int32.Parse(level);

            for (int i = 0; i < endAt; i++)
            {
                Console.ReadKey();
                Event someEvent = eventMaker.getEvent();
                if (character.getUpdateStatus())
                {
                    someEvent.getBuffedCharacter(character);
                    Console.WriteLine("Choose a startegy:");
                    Console.WriteLine("1.Build a shelter.");
                    Console.WriteLine("2.Make some clothes to wear.");
                    Console.WriteLine("3.Go find a new area to live in.");
                    Console.WriteLine("Do nothing (type anything exept 1, 2 or 3)");
                    SurvivalStrategy strategy;
                    string           strategyChoice = Console.ReadLine();
                    switch (strategyChoice)
                    {
                    case "1":
                        strategy = new BuildingStrategy();
                        break;

                    case "2":
                        strategy = new DressingStrategy();
                        break;

                    case "3":
                        strategy = new ExploringStrategy();
                        break;

                    default:
                        strategy = new NothingStrategy();
                        break;
                    }

                    string strategyDescription = strategy.useStrategy();

                    Console.WriteLine(strategyDescription);

                    if (strategyDescription == "You do nothing")
                    {
                        character = someEvent.getBuffedCharacter(character);
                        eventMaker.removeAll();
                        eventMaker.add(character);
                        Console.WriteLine(character.getDescription());
                        Console.WriteLine("New moral is " + character.getMoral());

                        if (character.getMoral() <= 0)
                        {
                            Console.WriteLine("You got to the end of your desire to live. So you end it all.");
                            Console.WriteLine("G A M E  I S  O V E R !");
                            return;
                        }
                    }
                    else
                    {
                        Console.WriteLine("New moral is " + character.getMoral());
                    }
                }
                else
                {
                    character = someEvent.getBuffedCharacter(character);
                    eventMaker.removeAll();
                    eventMaker.add(character);
                    Console.WriteLine(character.getDescription());
                    Console.WriteLine("New moral is " + character.getMoral());

                    if (character.getMoral() <= 0)
                    {
                        Console.WriteLine("You got to the end of your desire to live. So you end it all.");
                        Console.WriteLine("G A M E  I S  O V E R !");
                        return;
                    }
                }
            }
            Console.WriteLine("G A M E  I S  O V E R !");

            Console.ReadKey();
        }
Example #20
0
 void Start()
 {
     player           = GameObject.FindWithTag("Player").GetComponent <BasicCharacter> ();
     Cursor.visible   = false;
     Cursor.lockState = CursorLockMode.Locked;
 }