private static void SendCommand(ChakraMode mode, Chakra chakra, string options)
        {
            var command = $"{(int) mode}|{(int) chakra}|{options}";

            Debug.Log(command);
            Controller.SendData(command);
        }
        public static Color SetRandomColor(Chakra chakra)
        {
            var color = new Color(Random.value, Random.value, Random.value);

            SendCommand(ChakraMode.StaticColor, chakra, ColorToCommand(color));

            return(color);
        }
    public EnemyState(Vector3 pos, Vector3 rot, float health, Chakra chakra)
    {
        this.posX = pos.x;
        this.posY = pos.y;
        this.posZ = pos.z;

        this.rotX = rot.x;
        this.rotY = rot.y;
        this.rotZ = rot.z;

        this.health = health;
        this.chakra = chakra;
    }
    /// <summary>
    /// Player Save Constructor
    /// </summary>
    public PlayerSaveData()
    {
        Vector3 pos = Player.m_Player.GetPosition();
        this.posX = pos.x;
        this.posY = pos.y;
        this.posZ = pos.z;

        Vector3 rot = Player.m_Player.GetRotation();
        this.rotX = rot.x;
        this.rotY = rot.y;
        this.rotZ = rot.z;

        this.health = Player.m_Player.Health;
        this.maxHealth = Player.m_Player.MaxHealth;

        this.rotationDamping = Player.m_Player.RotationDamp;
        this.runMulti = Player.m_Player.RunMulti;
        this.jumpMulti = Player.m_Player.JumpMulti;
        this.gravity = Player.m_Player.Gravity;

        this.chakra = Player.m_Player.Chakra;
    }
Beispiel #5
0
 public void Init()
 {
     target = Player.m_Player;
     chakra = new Chakra(ChakraType.Water, 1, 10, 3, 1.2f);
 }
Beispiel #6
0
 /// <summary>
 /// Set Player Parameters
 /// </summary>
 /// <param name="runMulti"></param>
 /// <param name="jumpMulti"></param>
 /// <param name="gravity"></param>
 /// <param name="rotationDamp"></param>
 /// <param name="startHealth"></param>
 /// <param name="hitPointColor"></param>
 /// <param name="distance"></param>
 public void SetPlayerParams(float health, float maxHealth, float runMulti, float jumpMulti, int gravity, float rotationDamp, Chakra chakra)
 {
     this.health = health;
     this.maxHealth = maxHealth;
     this.rotationDamp = rotationDamp;
     this.runMulti = runMulti;
     this.jumpMulti = jumpMulti;
     this.gravity = gravity;
     this.chakra = chakra;
     active = true;
 }
    private static void HealthDamage(IDamageable defender, Chakra attackerChakra)
    {
        Chakra defenderChakra = defender.GetChakra();
        float damage = ChakraAttackValue(attackerChakra, defenderChakra)
            - defenderChakra.DefencePower;

        if (damage < 1.0f)
            damage = 1.0f;

        defender.Damage(damage);
    }
    private static float ChakraAttackValue(Chakra attackChakra, Chakra defenceChakra)
    {
        if (attackChakra.StrongAgainst == defenceChakra.Chakratype)
            return attackChakra.AttackPower + (attackChakra.AttackPower/2);

        if (attackChakra.WeakAgainst == defenceChakra.Chakratype)
            return attackChakra.AttackPower - (attackChakra.AttackPower/2);

        return attackChakra.AttackPower;
    }
 /// <summary>
 /// Chakra Fire.
 /// 1. Fires a raycast to look for an object tagged Player or Enemy
 /// 2. If the object is IDamagaeable. Applies HealthDamage()
 /// </summary>
 /// <param name="attackerChakra">Attacking Chakra</param>
 /// <param name="spawnPoint">SpawnPoint of raycast</param>
 /// <param name="direction">Direction of raycast</param>
 public static void ChakraFire(Chakra attackerChakra, Vector3 spawnPoint, Vector3 direction)
 {
     RaycastHit hit;
     Debug.DrawRay(spawnPoint, direction.normalized * attackerChakra.MaxAttackDistance);
     if (Physics.Raycast(spawnPoint, direction.normalized * attackerChakra.MaxAttackDistance, out hit))
     {
         // Only effects player or enemy
         if ((hit.collider.CompareTag("Enemy") || hit.collider.CompareTag("Player")) &&
             // hit distance is less then max attack distance
             hit.distance <= attackerChakra.MaxAttackDistance)
         {
             // If damageable apply health damage.
             IDamageable damageable = (IDamageable)hit.collider.gameObject.GetComponent(typeof(IDamageable));
             if (damageable != null)
                 HealthDamage(damageable, attackerChakra);
         }
     }
 }