コード例 #1
0
    void Update()
    {
        Animate();

        if (0 == self.hp)
        {
            return;
        }

        Debug.Assert(enemy != null);
        if (Global.invert > 0)
        {
            return;
        }
        Collect();

        // target = Quaternion.AngleAxis(180, Vector3.up);
        // var urg = 0.5f;

        var urg = bot.baseSpeed;

        urg += bot.stress * underFire * (1 - bot.baseSpeed);

        switch (action)
        {
        case Action.Cover:
            // urg = bot.coverSpeed + stress * (1 - bot.coverSpeed);
            Move(cover.NearestCover(transform.position.x) > 0 ? 1 : -1, urg);
            break;

        case Action.Peek:
            // urg = bot.peekSpeed;
            Peek(urg);
            break;

        case Action.Aim:
            var guess = lastTarget - transform.position;
            guess.Normalize();
            target = Quaternion.LookRotation(guess, Vector3.up);
            break;

        case Action.Fire:
            self.Shoot(enemy);
            break;

        case Action.Switch:
            var side = switchSide;
            // urg = bot.switchSpeed;
            Move(switchSide, urg);
            break;

        case Action.Hide:
            break;

        case Action.C**k:
            self.C**k();
            break;

        case Action.Recover:
            Recover();
            break;
        }

        timer += Time.deltaTime;
        var t = bot.aim * Time.deltaTime;

        self.manual = Quaternion.Slerp(self.manual, target, t);
    }
コード例 #2
0
ファイル: Player.cs プロジェクト: acgaudette/ludum46
    void Control()
    {
        if (Input.GetKeyDown(KeyCode.Equals))
        {
            Global.Sens = Mathf.Clamp(Global.Sens + 1, 1, 50);
            sensTimer   = 1;
        }

        if (Input.GetKeyDown(KeyCode.Minus))
        {
            Global.Sens = Mathf.Clamp(Global.Sens - 1, 1, 50);
            sensTimer   = 1;
        }

        if (Input.GetKeyDown(KeyCode.LeftBracket))
        {
            Global.Volume = Mathf.Clamp(Global.Volume - 1, 0, 10);
            volTimer      = 1;
        }

        if (Input.GetKeyDown(KeyCode.RightBracket))
        {
            Global.Volume = Mathf.Clamp(Global.Volume + 1, 0, 10);
            volTimer      = 1;
        }

        if (Input.GetKeyDown(KeyCode.X))
        {
            Global.XActive = !Global.XActive;
        }

        if (0 == self.hp)
        {
            return;
        }

        if (Global.invert > 0)
        {
            return;
        }

        var right = (
            Input.GetKeyDown(KeyCode.D) ||
            Input.GetKeyDown(KeyCode.L)
            ) ? 1 : 0;

        var left = (
            Input.GetKeyDown(KeyCode.A) ||
            Input.GetKeyDown(KeyCode.H)
            ) ? -1 : 0;

        int dir = left + right;

        if (dir != 0)
        {
            cam.heart += 0.1f;
            self.Tap(dir);
        }

        /* Screen size dependent, but the alternative is broken on linux
         * self.look = Input.mousePosition.x / Screen.width;
         * self.look = 2 * self.look - 1;
         */

        var sens = Global.Sens / 100.0f;

        self.look += Input.GetAxis("Mouse X") * sens;
        self.look  = Mathf.Max(-1, Mathf.Min(1, self.look));

        var fire = Input.GetKeyDown(KeyCode.Space) ||
                   Input.GetMouseButtonDown(0);

        if (fire)
        {
            self.Shoot();
        }

        var c**k = Input.GetKeyDown(KeyCode.LeftAlt) ||
                   Input.GetMouseButtonDown(1);

        if (c**k)
        {
            self.C**k();
        }
    }