Пример #1
0
        public object Get(EventJunction request)
        {
            switch (request.Junction.ToLower().TrimAndPruneSpaces())
            {
            case "comment":
                return(GetJunctionSearchResult <Event, DocEntityEvent, DocEntityComment, Comment, CommentSearch>((int)request.Id, DocConstantModelName.COMMENT, "Comments", request, (ss) => HostContext.ResolveService <CommentService>(Request)?.Get(ss)));

            case "favorite":
                return(GetJunctionSearchResult <Event, DocEntityEvent, DocEntityFavorite, Favorite, FavoriteSearch>((int)request.Id, DocConstantModelName.FAVORITE, "Favorites", request, (ss) => HostContext.ResolveService <FavoriteService>(Request)?.Get(ss)));

            case "tag":
                return(GetJunctionSearchResult <Event, DocEntityEvent, DocEntityTag, Tag, TagSearch>((int)request.Id, DocConstantModelName.TAG, "Tags", request, (ss) => HostContext.ResolveService <TagService>(Request)?.Get(ss)));

            case "team":
                return(GetJunctionSearchResult <Event, DocEntityEvent, DocEntityTeam, Team, TeamSearch>((int)request.Id, DocConstantModelName.TEAM, "Teams", request, (ss) => HostContext.ResolveService <TeamService>(Request)?.Get(ss)));

            case "update":
                return(GetJunctionSearchResult <Event, DocEntityEvent, DocEntityUpdate, Update, UpdateSearch>((int)request.Id, DocConstantModelName.UPDATE, "Updates", request, (ss) => HostContext.ResolveService <UpdateService>(Request)?.Get(ss)));

            case "user":
                return(GetJunctionSearchResult <Event, DocEntityEvent, DocEntityUser, User, UserSearch>((int)request.Id, DocConstantModelName.USER, "Users", request, (ss) => HostContext.ResolveService <UserService>(Request)?.Get(ss)));

            default:
                throw new HttpError(HttpStatusCode.NotFound, $"Route for event/{request.Id}/{request.Junction} was not found");
            }
        }
Пример #2
0
    public virtual void Damage(int damageAmount, Entity origin, DamageType damageSource)
    {
        // Abort if already dead, unless the 'corpse' can be desecrated further
        if (IsDead && allowPostmortemDamage == false)
        {
            return;
        }

        values.current  -= damageAmount;
        lastAttacker     = origin;
        lastDamageSource = damageSource;

        // Play appropriate event
        if (damageAmount >= 0)
        {
            onDamage.Invoke();
        }
        else
        {
            onHeal.Invoke();
        }

        EventJunction.Transmit(new DamageMessage(origin, this, damageSource, damageAmount));

        if (values.current <= 0)
        {
            Die(lastDamageSource, lastAttacker);
        }
    }
Пример #3
0
    private void Awake()
    {
        // Add important functions to eventobserver
        EventJunction.Subscribe(CheckKillObjectives, true);


        //CompleteLevel();
    }
Пример #4
0
    // Use this for initialization
    void Start()
    {
        SetCrouchVisualEffects(player.movement.isCrouching);
        PopulateInteractionMenu(null);

        EventJunction.Subscribe(CheckToUpdateHealthMeter, true);
        EventJunction.Subscribe(CheckForHitMarker, true);
        EventJunction.Subscribe(CheckForKillMarker, true);
    }
    public virtual void OnInteract(PlayerHandler ph)
    {
        onInteract.Invoke(ph);
        EventJunction.Transmit(new InteractMessage(ph, this));

        if (cooldown > 0)
        {
            coolingDown = Cooldown(cooldown);
            StartCoroutine(coolingDown);
        }
    }
    public override void Telegraph()
    {
        base.Telegraph();

        //Vector3 direction = wielder.currentTarget.transform.position - wielder.LookOrigin;
        Vector3       direction = DetermineEnemyPosition() - wielder.LookOrigin;
        AttackMessage m         = AttackMessage.Ranged(wielder.characterData, wielder.LookOrigin, direction, stats.range, stats.projectilePrefab.diameter, stats.projectileSpread, stats.projectilePrefab.velocity, stats.projectilePrefab.hitDetection);

        EventJunction.Transmit(m);
        //EventObserver.TransmitAttack(m); // Transmits a message of the attack the player is about to perform
    }
Пример #7
0
    public virtual void Die(DamageType causeOfDeath, Entity lastAttacker)
    {
        if (IsDead)
        {
            return; // Character is already dead, no need to do anything
        }

        IsDead = true;
        onDeath.Invoke();
        EventJunction.Transmit(new KillMessage(lastAttacker, this, causeOfDeath));
    }
Пример #8
0
    void Update()
    {
        // Ensure things don't happen if the game is paused.
        if (Time.timeScale == 0)
        {
            return;
        }


        attackMessageLimitTimer += Time.deltaTime;

        // If the player is not switching weapons or fire modes, and is therefore able to operate the weapon
        if (isSwitchingWeapon == false && isSwitchingFireMode == false && playerHolding.weaponSelector.InSelection == false)
        {
            #region Firing mode controls
            float scrollInput = Input.GetAxis("Mouse ScrollWheel");
            if (scrollInput != 0 && firingModes.Length > 1) // Switch firing modes with the scroll wheel
            {
                int i = firingModeIndex;
                i -= (int)new Vector2(scrollInput, 0).normalized.x;
                i  = (int)Misc.InverseClamp(i, 0, firingModes.Length - 1);
                StartCoroutine(SwitchMode(i));
            }
            #endregion

            #region Fire controls
            fireControls.fireTimer += Time.deltaTime;

            // If player is active
            // If player is pressing fire button
            // If fireTimer has finished
            // If burst count has not exceeded the limit OR there is no burst limit
            // If ammo is available OR not required
            // If magazine is not empty OR null
            if (playerHolding.handler.PlayerState() == GameState.Active &&
                Input.GetButton("Fire") &&
                fireControls.fireTimer >= 60 / fireControls.roundsPerMinute &&
                (fireControls.burstCounter < fireControls.maxBurst || fireControls.maxBurst <= 0) &&
                (general.consumesAmmo == false || (playerHolding.handler.ammo.GetStock(general.ammoType) >= general.ammoPerShot)) &&
                (magazine == null || (magazine.data.current >= general.ammoPerShot && reloading == null)))
            {
                CancelReloadSequence();

                fireControls.fireTimer     = 0; // Reset fire timer to count up to next shot
                fireControls.burstCounter += 1;

                if (general.consumesAmmo == true)
                {
                    playerHolding.handler.ammo.Spend(general.ammoType, general.ammoPerShot);
                }

                if (magazine != null)
                {
                    magazine.data.current -= general.ammoPerShot;
                }

                recoilToApply += general.recoil;

                #region Calculate and fire shot
                Transform head         = playerHolding.handler.movement.head;
                Vector3   aimDirection = head.forward;
                if (optics == null || isAiming == false)
                {
                    float accuracy = playerHolding.standingAccuracy.Calculate();
                    aimDirection = Quaternion.Euler(Random.Range(-accuracy, accuracy), Random.Range(-accuracy, accuracy), Random.Range(-accuracy, accuracy)) * aimDirection;
                }

                general.Shoot(playerHolding.handler, head.position, aimDirection, head.up);
                #endregion

                #region Send attack message if the timer is right
                if (attackMessageLimitTimer >= attackMessageLimitDelay) // Sends attack message
                {
                    AttackMessage am = AttackMessage.Ranged(playerHolding.handler, transform.position, transform.forward, general.range, general.projectilePrefab.diameter, playerHolding.standingAccuracy.Calculate() + general.projectileSpread, general.projectilePrefab.velocity, general.projectilePrefab.hitDetection);
                    EventJunction.Transmit(am);


                    attackMessageLimitTimer = 0;
                }
                #endregion
            }
            else if (!Input.GetButton("Fire"))
            {
                fireControls.burstCounter = 0;
            }
            #endregion

            #region ADS and reload controls
            ADSHandler();

            /*
             * if (optics != null)
             * {
             *  optics.ADSHandler(this, currentMode);
             * }
             */
            ReloadHandler();
            #endregion
        }

        RecoilHandler(general.recoilApplyRate, playerHolding);
    }
Пример #9
0
 private void OnDisable()
 {
     EventJunction.Subscribe(Dodge, false);
 }
Пример #10
0
 private void OnEnable()
 {
     EventJunction.Subscribe(Dodge, true);
     //EventJunction.OnAttack += Dodge;
 }