Exemplo n.º 1
0
    public virtual void ChangeHealth(float value, Vector3 shotDir, Elements.Element ammoType)
    {
        //if (ammoType.ToString() == shieldElement.ToString())
        //{
        //    value += 5;
        //}

        //else if (ammoType.ToString() != shieldElement.ToString())
        //{
        //    return;
        //}

        value = CheckWeakness(value, ammoType);

        currentHealth -= value;

        if (value != 0)
        {
            if (value < 0)
            {
                onHeal.Invoke();
                updateHealthBarEvent.Invoke(currentHealth, maxHealth);
            }
            if (value > 0)
            {
                onDamage.Invoke();
                updateHealthBarEvent.Invoke(currentHealth, maxHealth);
            }
        }
        CheckDie();
    }
Exemplo n.º 2
0
    public Color GetTrailColorBasedOn(Elements.Element ammoType)
    {
        // set shotDirArm color
        switch (ammoType)
        {
        case Elements.Element.Normal:
            Debug.Log("Element: " + ammoType);
            return(normal);

        case Elements.Element.Fire:
            Debug.Log("Element: " + ammoType);
            return(fire);

        case Elements.Element.Water:
            Debug.Log("Element: " + ammoType);
            return(water);

        case Elements.Element.Grass:
            Debug.Log("Element: " + ammoType);
            return(grass);

        default:
            Debug.Log("You Need to add a new Color/Element to Weapon to asign to bullet trail color");
            return(normal);
        }
    }
Exemplo n.º 3
0
        public ADSK.ElementId[] ToRevit(Elements.Element hyparElement, LoadContext context)
        {
            var createdElements = new List <ADSK.ElementId>();
            var floor           = hyparElement as Elements.Floor;
            var curves          = floor.Profile.Perimeter.ToRevitCurveArray(true);
            var floorType       = new ADSK.FilteredElementCollector(context.Document)
                                  .OfClass(typeof(ADSK.FloorType))
                                  .OfType <ADSK.FloorType>()
                                  .First(e => e.Name.Contains("Generic"));

            double offsetFromLevel = 0;
            var    level           = context.Level ?? FromHyparExtensions.GetLevelClosestToZ(Units.MetersToFeet(floor.Elevation), context.Document, out offsetFromLevel);
            var    rvtFloor        = context.Document.Create.NewFloor(curves, floorType, level, false, ADSK.XYZ.BasisZ);

            context.Document.Regenerate(); // we must regenerate the document before adding openings
            var allOpenings = floor.Openings.Select(o => o.Perimeter).Union(floor.Profile.Voids);

            foreach (var opening in allOpenings)
            {
                var openingProfile = opening.ToRevitCurveArray(true);
                var rvtOpen        = context.Document.Create.NewOpening(rvtFloor, openingProfile, true);
                createdElements.Add(rvtOpen.Id);
            }

            offsetFromLevel += Units.MetersToFeet(floor.Thickness);
            rvtFloor.LookupParameter("Height Offset From Level")?.Set(Units.MetersToFeet(offsetFromLevel));
            createdElements.Add(rvtFloor.Id);
            return(createdElements.ToArray());
        }
Exemplo n.º 4
0
    public void SetShieldElement(Elements.Element _shieldElement)
    {
        if (!shieldMat)
        {
            shieldMat = GetComponent <Renderer>().material;
        }
        int elementIndex = (int)_shieldElement;

        shieldMat.SetColor("_ShieldPatternColor", shieldColor[elementIndex]);
    }
Exemplo n.º 5
0
    public void BulletTrail(Vector3 target, float distance, Elements.Element bulletType)
    {
        Debug.Log("b trail");
        GameObject bulletPath = Instantiate(lineRendPrefab, shootPoint.position, shootPoint.rotation);

        bulletPath.transform.SetParent(shootPoint);
        bulletPath.GetComponent <LineRenderer>().materials[0].SetColor("_TintColor", GetTrailColorBasedOn(bulletType));
        BulletPath script = bulletPath.GetComponent <BulletPath>();

        script.target   = target;
        script.distance = distance;
    }
Exemplo n.º 6
0
 public static void SetNode(TreeNode<Element> node, Element element)
 {
     node.Tag = element;
     if (element.IsValid)
     {
         //node. = ElementType.Character;
         //node.ImageIndex = 2;
         //node.SelectedImageIndex = 2;
         return;
     }
     //node.ForeColor = Color.Red;
     //node.ImageIndex = 1;
     //node.SelectedImageIndex = 1;
 }
Exemplo n.º 7
0
    public override void ChangeHealth(float _value, Vector3 shotOrigin, Elements.Element ammoType)
    {
        // tell AI it's been shot
        ai.BulletAlert(shotOrigin);

        if (!isGod)
        {
            if (currentShield > 0)
            {
                shield.gameObject.SetActive(true);

                _value = CheckWeakness(_value, ammoType);

                if (currentShield > _value)
                {
                    currentShield -= _value;
                }
                else if (_value >= currentShield)
                {
                    carryOnDmg     = _value - currentShield;
                    currentShield -= _value;
                    currentHealth -= carryOnDmg;

                    currentShield = currentShield < 0 ? 0 : currentShield;

                    CheckDie();
                }
            }
            else if (currentShield <= 0)
            {
                currentShield = 0;
                shield.gameObject.SetActive(false);

                if (currentHealth > 0)
                {
                    currentHealth -= _value;

                    if (currentHealth > maxHealth)
                    {
                        currentHealth = maxHealth;
                    }

                    CheckDie();
                }
            }
        }
    }
Exemplo n.º 8
0
    IEnumerator ShotDirectionActive(Vector3 incoming, Elements.Element ammoType)
    {
        //Set shotDirArm color
        switch (ammoType)
        {
        case Elements.Element.Normal:
            shotDirImage.color = normal;
            Debug.Log("normal");
            break;

        case Elements.Element.Fire:
            shotDirImage.color = fire;
            Debug.Log("fire");
            break;

        case Elements.Element.Water:
            shotDirImage.color = water;
            Debug.Log("water");
            break;

        case Elements.Element.Grass:
            shotDirImage.color = grass;
            Debug.Log("grass");
            break;

        default:
            Debug.Log("You Need to assign a new Color/Element to ShotDirection");
            break;
        }
        shotDirImage.enabled = true;
        float timer = 0;

        while (timer < shotIndicatorDelay)
        {
            timer += Time.deltaTime;
            // Angle between other pos vs player
            Vector3 incomingDir = (playerPos.position - incoming).normalized;
            // Flatten to plane
            Vector3 otherDir  = new Vector3(-incomingDir.x, 0f, -incomingDir.z);
            var     playerFwd = Vector3.ProjectOnPlane(playerPos.forward, Vector3.up);
            // Direction between player fwd and incoming object
            var angle = Vector3.SignedAngle(playerFwd, otherDir, Vector3.up);
            transform.rotation = Quaternion.Euler(0, 0, -angle);
            yield return(null);
        }
        shotDirImage.enabled = false;
    }
Exemplo n.º 9
0
    public override void ChangeHealth(float _value, Vector3 _shotDir, Elements.Element ammoType)
    {
        if (currentShield > 0)
        {
            shield.gameObject.SetActive(true);

            if (currentShield > _value)
            {
                currentShield -= _value;
            }
            else if (_value >= currentShield)
            {
                carryOnDmg     = _value - currentShield;
                currentShield -= _value;
                currentHealth -= carryOnDmg;

                currentShield = currentShield < 0 ? 0 : currentShield;

                CheckDie();
            }
        }
        else if (currentShield <= 0)
        {
            currentShield = 0;
            shield.gameObject.SetActive(false);

            if (currentHealth > 0)
            {
                currentHealth -= _value;

                //print(_value > 0 ? string.Format("Health reduced by {0} and is now {1}", _value, currentHealth) : string.Format("Health healed by {0} and is now {1}", -_value, currentHealth));

                if (currentHealth > maxHealth)
                {
                    currentHealth = maxHealth;
                }

                //If you're actually being damaged (negative means healing)
                if (_value > 0)
                {
                    UI.shotDirection.ShotIndicator(_shotDir, ammoType);
                }

                CheckDie();
            }
        }
    }
Exemplo n.º 10
0
    private void HandleElementCreation(Elements.Element element)
    {
        element.DataChanged += (sender, args) =>
        {
            switch (args.SyncType)
            {
            case DataSyncType.Broadcast:
                var packet = new SetElementDataRpcPacket(sender.Id, args.Key, args.NewValue);
                this.server.BroadcastPacket(packet);
                break;

            case DataSyncType.Subscribe:
                new SetElementDataRpcPacket(sender.Id, args.Key, args.NewValue)
                .SendTo(element.GetPlayersSubcribedToData(args.Key));
                break;
            }
        };
    }
Exemplo n.º 11
0
    public float CheckWeakness(float _val, Elements.Element ammoType)
    {
        print("I am checking shield weakness!");
        if (ammoType == Elements.Element.Fire && shieldElement == Elements.Element.Grass)
        {
            _val = _val * 1.25f;
        }

        else if (ammoType == Elements.Element.Water && shieldElement == Elements.Element.Fire)
        {
            _val = _val * 1.25f;
        }

        else if (ammoType == Elements.Element.Grass && shieldElement == Elements.Element.Water)
        {
            _val = _val * 1.25f;
        }
        //print(_val);

        return(_val);
    }
Exemplo n.º 12
0
    /// <summary>
    /// Always call base.Awake() when overriding this!
    /// <para>This calls updatefloats() at its end. Remember that.</para>
    /// </summary>
    public virtual void Awake()
    {
        user        = gameObject.GetComponent <Person>();
        abilityName = this.GetType().ToString();
        element     = (Elements.Element)System.Enum.Parse(typeof(Elements.Element), getElementName());

        // default values.
        range         = -1;
        cooldown      = -1;
        cost          = -1;
        costPerSecond = -1;
        radius        = -1;
        damage        = -1;
        pushback      = -1;
        steal         = -1;
        duration      = -1;
        chance        = -1;
        amount        = -1;
        chargeRate    = -1;

        verticalRange = 4; // default value.

        cooldownLeft     = 0;
        instant          = false;
        maintainable     = false;
        stopsMovement    = false;
        toggleable       = false;
        on               = false;
        costType         = CostType.NONE;
        rangeType        = RangeType.NONE;
        timeLeft         = 0;
        disabled         = false;
        prepareToDisable = false;
        prepareToEnable  = false;
        natural          = false;

        updateTags();
        initStats();
    }
Exemplo n.º 13
0
    public void ApplyUniqueWeaponStats(UniqueWeaponStats _uniqueStats)
    {
        // Get Array of all variable names in class
        var weaponVariableNames = this.GetType()
                                  .GetFields()
                                  .Select(field => field.Name);

        // Get Array of all stat multipliers in uniqueStats (paramater)
        var uniqueVariableNames = _uniqueStats.GetType()
                                  .GetFields()
                                  .Select(field => field.Name);

        _uniqueStats.baseStats.Clear();
        // Match variav\ble pairs with same name
        foreach (var multi in uniqueVariableNames)
        {
            if (weaponVariableNames.Contains(multi))
            {
                // Get field on weapon(as FieldInfo)
                var statField = this.GetType().GetField(multi);
                // Get matching field on UniqueWeaponStats class
                var statMultiplier = _uniqueStats.GetType().GetField(multi);

                try
                {
                    // Collect weapon's base stats to reapply to it later (if weapon dropped)
                    _uniqueStats.baseStats.Add(multi, Convert.ToSingle(statField.GetValue(this)));
                }
                catch
                {
                    Debug.Log("catch: " + multi);
                    _uniqueStats.baseStats.Add(multi, 0);
                }


                // if statfield is an int - cast it as such when applying value
                if (statField.GetValue(this) is int)
                {
                    int newValue = Mathf.RoundToInt(((int)statField.GetValue(this) * (float)statMultiplier.GetValue(_uniqueStats)));
                    statField.SetValue(this, newValue);
                }
                else if (statField.GetValue(this) is float)// if statfield is an float - cast it as such when applying value
                {
                    float newValue = (float)statField.GetValue(this) * (float)statMultiplier.GetValue(_uniqueStats);
                    newValue = (float)Math.Round((double)newValue, 2);
                    statField.SetValue(this, newValue);
                }
                else
                {
                    Debug.Log("SETTING ENUM");
                    Elements.Element newValue = (Elements.Element)statMultiplier.GetValue(this);
                    statField.SetValue(this, newValue);
                }
            }
            else
            {
                //Debug.Log("UniqueWeaponStats variable: " + multi + ", does not have a counterpart to mutate in weapon script");
            }
        }
        uniqueStats = _uniqueStats;
    }
Exemplo n.º 14
0
 public ADSK.ElementId[] ToRevit(Elements.Element hyparElement, LoadContext context)
 {
     return(DSFromEnvelope(hyparElement, context));
 }
 public virtual void Add(Element element)
 {
     base.List.Add(element);
 }
Exemplo n.º 16
0
 public void ShotIndicator(Vector3 incoming, Elements.Element ammoType)
 {
     StopAllCoroutines();
     StartCoroutine(ShotDirectionActive(incoming, ammoType));
 }
Exemplo n.º 17
0
 // Where we take damage and check if we can die.
 public override void ChangeHealth(float value, Vector3 shotDir, Elements.Element ammoType)
 {
     currentHealth -= value;
     CheckDie();
     Debug.Log("Totem Hit. Remaining health: " + currentHealth);
 }
Exemplo n.º 18
0
 public ElementId[] ToRevit(Elements.Element hyparElement, LoadContext context)
 {
     throw new NotImplementedException();
 }