private void TentacleAttackHaptics(float dmg, Agents.Agent sourceAgent, Vector3 position)
        {
            if (!VRConfig.configUseBhaptics.Value || sourceAgent != m_player)
            {
                return;
            }

            if (m_lastDamageRotationOption != null)
            {
                var rotationOption = m_lastDamageRotationOption;
                //var rotationOption = GetRotationOptionFromDirection(position - sourceAgent.TentacleTarget.position); // could maybe calculate direction with this, but offsetY is not right
                m_hapticPlayer.SubmitRegisteredVestRotation(VEST_TENTACLE_ATTACK_KEY, rotationOption);
            }
            else
            {
                Log.Error("Received tentacle attack with no last damage rotation option!");
            }
        }
 // Start is called before the first frame update
 private void Start()
 {
     gather.onClick.AddListener(
         () =>
     {
         Interaction.Gather(gatherNodeID, gatherAmount);
         agentDoingActionRef.ProcessAction();
         GameActionsLogger.instance.LogAction($"<b>{agentDoingActionRef.name}</b> just <color=green>gathered</color> {gatherNodeID} from <b>{gatherNodeRef.name}</b>");
         Destroy(gatherNodeRef);
         gatherAmount        = 0;
         gatherNodeID        = null;
         gatherNodeRef       = null;
         agentDoingActionRef = null;
         DisableActionButton(ActionType.Gather);
     });
     actionButtonPositionerImg = actionButtonPisitioner.GetComponent <Image>();
     positionerColor           = actionButtonPositionerImg.color;
 }
    internal virtual void SpawnEnemy()
    {
        if (currentTile == null)
        {
            return;
        }
        if (assetSpawner == null)
        {
            return;
        }

        try
        {
            GameObject go = assetSpawner.SpawnAssetGeneric(
                asset: agentToSpawn,                            //the agent we want to spawn into the world
                assetName: agentToSpawn.name,                   //the name of the agent, e.g: skeleton
                t: currentTile,                                 //the current tile the thing this is attached to is on
                spawnOntoRandomTileNeighbour: true              //whether we want this object to spawn automagically onto a randomly selected neighbour tile
                );

            if (!go.CompareTag("Enemy"))
            {
                go.tag = "Enemy";
            }
            Tile goT = go.GetComponent <Tile>();
            goT.Type = Tile.TileType.Enemy;
            Agents.Agent      spawnedAgent = go.GetComponent <Agents.Agent>();
            AISuperSimpleMove aiMover      = go.AddComponent <AISuperSimpleMove>();
            spawnedAgent.Init(agentConfig, aiMover);
            aiMover.Init(spawnedAgent, agentConfig, go.transform.parent.GetComponent <Tile>());
            TurnManagement.AgentTurnSetter.AddAgentToStateMachine(spawnedAgent);
            amountOfAgentsSpawned++;
            go.name += $" ({amountOfAgentsSpawned})";
        }
        catch { /*please don't do what I'm doing here*/ }
    }
Beispiel #4
0
        static public Agents.Agent buildCharacter(string uname)
        {
            uname = uname.TrimStart(new char[] { '\0', ':' });
            try
            {
                if (!connDB.State.HasFlag(ConnectionState.Open))
                {
                    connDB.Open();
                }
            }
            catch (OdbcException e)
            {
                Console.WriteLine(e.Message + "\n\n" + e.StackTrace);
            }

            data = new DataSet();
            dbAdapter.SelectCommand = new OdbcCommand("SELECT * FROM users WHERE twitch_name='" + uname + "';", connDB);
            dbAdapter.Fill(data);

            if (data.Tables[0].Rows.Count == 0)
            {
                throw new Game.Exceptions.NoSuchPlayerException("There is no " + uname + " in the database.");
            }

            var levelBoost = .04 * float.Parse(data.Tables[0].Rows[0]["level"].ToString());

            levelBoost += 1;

            Abstracts.Class spec = new Classes.Fighter();
            Abstracts.Race  race = new Races.Human();

            int temper    = (int)(levelBoost * float.Parse(data.Tables[0].Rows[0]["temper"].ToString()));
            int cheer     = (int)(levelBoost * float.Parse(data.Tables[0].Rows[0]["cheer"].ToString()));
            int curiosity = (int)(levelBoost * float.Parse(data.Tables[0].Rows[0]["curiosity"].ToString()));
            int charisma  = (int)(levelBoost * float.Parse(data.Tables[0].Rows[0]["charisma"].ToString()));
            int empathy   = (int)(levelBoost * float.Parse(data.Tables[0].Rows[0]["empathy"].ToString()));

            int baseHealth = race.getBaseHealth() + (int)((1f / 3f) * temper + (int)((1f / 4f) * empathy));

            Console.WriteLine("baseHealth" + baseHealth);
            int strength = race.getBaseStrength() + (int)((1f / 4f) * temper);

            Console.WriteLine("strength" + strength);
            int mind = race.getBaseMind() + (int)((1f / 3f) * curiosity);

            Console.WriteLine("mind" + mind);
            int mastery = (int)((1f / 2f) * empathy);

            Console.WriteLine("mastery" + mastery);
            int concentration = (int)((1f / 2f) * charisma);

            Console.WriteLine("concentration" + concentration);
            int spirit = race.getBaseSpirit() + (int)((1f / 3f) * cheer);
            var skills = new List <Abstracts.Skill>();
            int speed  = race.getBaseSpeed() + (int)((1f / 4f) * cheer) + (int)((1f / 4f) * charisma);

            Console.WriteLine("speed" + speed);
            Agents.Agent player = new Agents.Agent(baseHealth, strength, mind, concentration, mastery, spirit, skills, speed, spec, race, uname);
            connDB.Close();

            return(player);
        }
 public void SetGatherNodeRef(GameObject _gatherNodeRef, Agents.Agent _agentDoingActionRef)
 {
     agentDoingActionRef = _agentDoingActionRef;
     gatherNodeRef       = _gatherNodeRef;
 }
        static public Agents.Agent buildCharacter(string uname)
        {
            uname = uname.TrimStart(new char[] { '\0', ':' });
            try
            {
                if (!connDB.State.HasFlag(ConnectionState.Open))
                {
                    connDB.Open();
                }
            }
            catch (OdbcException e)
            {
                Console.WriteLine(e.Message + "\n\n" + e.StackTrace);
            }

            data = new DataSet();
            dbAdapter.SelectCommand = new OdbcCommand("SELECT * FROM users WHERE twitch_name='" + uname + "';", connDB);
            dbAdapter.Fill(data);

            if (data.Tables[0].Rows.Count == 0)
            {
                throw new Game.Exceptions.NoSuchPlayerException("There is no " + uname + " in the database.");
            }

            var levelBoost = .04 * float.Parse(data.Tables[0].Rows[0]["level"].ToString());

            levelBoost += 1;

            Abstracts.Class spec;
            Abstracts.Race  race;

            int temper    = (int)(levelBoost * float.Parse(data.Tables[0].Rows[0]["temper"].ToString()));
            int cheer     = (int)(levelBoost * float.Parse(data.Tables[0].Rows[0]["cheer"].ToString()));
            int curiosity = (int)(levelBoost * float.Parse(data.Tables[0].Rows[0]["curiosity"].ToString()));
            int charisma  = (int)(levelBoost * float.Parse(data.Tables[0].Rows[0]["charisma"].ToString()));
            int empathy   = (int)(levelBoost * float.Parse(data.Tables[0].Rows[0]["empathy"].ToString()));

            //[0] = highest stat
            //[1] = second highest stat
            //[2] = lowest stat
            int[] statpicks = new int[] { 0, 1, 0 };

            int[] stats = new int[] { temper, cheer, curiosity, charisma, empathy };

            for (int i = 1; i < 5; i++)
            {
                if (stats[i] > stats[statpicks[0]])
                {
                    statpicks[1] = statpicks[0];
                    statpicks[0] = i;
                }
                else if (stats[i] > stats[statpicks[1]])
                {
                    statpicks[1] = i;
                }

                if (stats[i] < stats[statpicks[2]])
                {
                    statpicks[2] = i;
                }
            }

            foreach (int stat in stats)
            {
                Console.WriteLine(stat);
            }
            foreach (int pick in statpicks)
            {
                Console.WriteLine(pick);
            }

            if ((statpicks[0] == 0 && statpicks[1] == 1) || (statpicks[0] == 1 && statpicks[1] == 0))
            {
                spec = new Classes.Barbarian();
            }
            else if ((statpicks[0] == 0 && statpicks[1] == 2) || (statpicks[0] == 2 && statpicks[1] == 0))
            {
                spec = new Classes.Sorcerer();
            }
            else if ((statpicks[0] == 0 && statpicks[1] == 3) || (statpicks[0] == 3 && statpicks[1] == 0))
            {
                spec = new Classes.Paladin();
            }
            else if ((statpicks[0] == 0 && statpicks[1] == 4) || (statpicks[0] == 4 && statpicks[1] == 0))
            {
                spec = new Classes.Fighter();
            }
            else if ((statpicks[0] == 1 && statpicks[1] == 2) || (statpicks[0] == 2 && statpicks[1] == 1))
            {
                spec = new Classes.Druid();
            }
            else if ((statpicks[0] == 1 && statpicks[1] == 3) || (statpicks[0] == 3 && statpicks[1] == 1))
            {
                spec = new Classes.Bard();
            }
            else if ((statpicks[0] == 1 && statpicks[1] == 4) || (statpicks[0] == 4 && statpicks[1] == 1))
            {
                spec = new Classes.Cleric();
            }
            else if ((statpicks[0] == 2 && statpicks[1] == 3) || (statpicks[0] == 3 && statpicks[1] == 2))
            {
                spec = new Classes.Wizard();
            }
            else if ((statpicks[0] == 2 && statpicks[1] == 4) || (statpicks[0] == 4 && statpicks[1] == 2))
            {
                spec = new Classes.Warlock();
            }
            else
            {
                spec = new Classes.Rogue();
            }

            Console.WriteLine(spec.getName());

            if ((statpicks[0] == 1 && statpicks[2] == 0))
            {
                race = new Races.Halfling();
            }
            else if ((statpicks[0] == 0 && statpicks[2] == 3))
            {
                race = new Races.Orc();
            }
            else if ((statpicks[0] == 4 && statpicks[2] == 1) || (statpicks[0] == 3 && statpicks[2] == 1))
            {
                race = new Races.Drow();
            }
            else if ((statpicks[0] == 4 && statpicks[2] == 0))
            {
                race = new Races.Tiefling();
            }
            else if ((statpicks[0] == 2 && statpicks[2] == 4) || (statpicks[0] == 3 && statpicks[2] == 4))
            {
                race = new Races.Gnome();
            }
            else if ((statpicks[0] == 2 && statpicks[2] == 1) || (statpicks[0] == 3 && statpicks[2] == 0))
            {
                race = new Races.Elf();
            }
            else if ((statpicks[0] == 0 && statpicks[2] == 1) || (statpicks[0] == 2 && statpicks[2] == 3))
            {
                race = new Races.HalfElf();
            }
            else if ((statpicks[0] == 1 && statpicks[2] == 4) || (statpicks[0] == 1 && statpicks[2] == 3) ||
                     (statpicks[0] == 4 && statpicks[2] == 2) || (statpicks[0] == 3 && statpicks[2] == 2))
            {
                race = new Races.Dwarf();
            }
            else
            {
                race = new Races.Human();
            }



            int baseHealth = race.getBaseHealth() + (int)((1f / 3f) * temper + (int)((1f / 4f) * empathy));
            //Console.WriteLine("baseHealth" + baseHealth);
            int strength = race.getBaseStrength() + (int)((1f / 4f) * temper);
            //Console.WriteLine("strength" + strength);
            int mind = race.getBaseMind() + (int)((1f / 3f) * curiosity);
            //Console.WriteLine("mind" + mind);
            int mastery = (int)((1f / 2f) * empathy);
            //Console.WriteLine("mastery" + mastery);
            int concentration = (int)((1f / 2f) * charisma);
            //Console.WriteLine("concentration" + concentration);
            int spirit = race.getBaseSpirit() + (int)((1f / 3f) * cheer);
            var skills = new List <Abstracts.Skill>();

            if (spec.getBaseSkill() != null)
            {
                skills.Add(spec.getBaseSkill());
            }
            int speed = race.getBaseSpeed() + (int)((1f / 4f) * cheer) + (int)((1f / 4f) * charisma);

            //Console.WriteLine("speed" + speed);

            connDB.Close();
            var actionPriority = spec.getActionPriority();
            var type           = "Player";

            Agents.Agent player = new Agents.Agent(uname, baseHealth, strength, mind, concentration, mastery, spirit, 0, skills, speed, null, actionPriority, type);


            return(player);
        }